In this WordPress tutorial, I’ll show you how to fix the JetEngine Profile Builder logout button when it is not working inside the account menu.
If you are using Bricks Builder, JetEngine, JetProfile Builder, or Crocoblock Profile Builder, you may notice that adding a Logout menu item creates a URL like /account/logout/, but it does not actually log the user out.
In this video, I show a simple Code Snippets fix that makes the JetEngine logout menu item work correctly.
Code used in this tutorial:
add_action('template_redirect', function () {
$path = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
if (is_user_logged_in() && $path === 'account/logout') {
wp_logout();
wp_safe_redirect(home_url('/login/'));
exit;
}
});
Important:
If your account page slug is different, change this part:
account/logout
Example:
my-account/logout
Tools used:
WordPress
Bricks Builder
JetEngine
JetEngine Profile Builder
Code Snippets plugin
Subscribe to WPBuilderFix for more WordPress, Bricks Builder, JetEngine, Crocoblock, and dynamic website tutorials.