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 be displayed when users click on the Logout link on the account page.
The pop-up will also display a custom message (Are you sure you want to log out?)

Code Preview
php
<?php
add_action('wp_head', function() { ?>
<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 });

Comments

Add a Comment