Home / Archive / MemberPress: Add Logout Confirmation Popup
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Add Logout Confirmation Popup

This code will force a confirmation popup to show when users click the Logout link on the account.

Note: This doesn't work with ReadyLaunch™ enabled on the account page.

Code Preview
php
<?php
function mepr_add_logout_confirmation() { 
?>
<script>
(function($) {
  $(document).ready(function() {
    var logout = $('#mepr-account-logout');
    if(logout.length) {
      $(logout).on('click', function(e) {
        if(!confirm('Are you sure you want to log out?')) {
          e.preventDefault();
        };
      });
    }
  });
})(jQuery);
</script>
<?php 
}
add_action( 'wp_head', 'mepr_add_logout_confirmation' );

Comments

Add a Comment