Adding Login Logout Menu Filters to Your WordPress Website

LoginPress is a WordPress login page customizer plugin that enables you to customize the login page for your WordPress site according to your requirements. Did you know you can even add filters?

LoginPress has a cool Add-on called  Login Logout Menu.

When you activate this Add-on, you can add the login and logout menu to any place on your WordPress site. The Login Logout Menu items will change when a user Logs in or out.

This knowledgebase article will explain how to use the Login Logout Menu Filter for redirect purposes to the following places.

Adding filters will be done with coding, so buckle up!

Let’s get started!

1. Filter To Redirect A User To A Specific Page After Logout

If you want to redirect a user after logging out to a specific page. You have to add the given line of code to your website theme's file "functions.php" and save the code.

Note: It’s recommended to use a child theme to edit the functions.php file instead of the parent theme. There are chances to lose the modified code when you update your theme. It might cause some adverse effects on your website.

/**
 * Filter to redirect a user to a specific page after logout.
 * @return [URL] logout URL with page slug on which it will be redirected after logout
 */
add_filter( 'login_logout_menu_logout', 'loginpress_login_menu_logout_redirect' );
function loginpress_login_menu_logout_redirect() {
 return wp_logout_url( '/hello-world' );
}

Let’s see what happens when you’ll log out now:

Login Logout Menu Filters

You’ll be redirected to the “hello-world” page as given in the filter:

Login with Facebook Button

2. Filter To Redirect After Successful Login

If you want to redirect users to another specific page after login instead of the site dashboard page, then you have o add the following piece of code in your website theme's "functions.php" and save the code.

Note: It’s recommended to use a child theme to edit the functions.php file instead of the parent theme. There are chances to lose the modified code when you update your theme. It might cause some adverse effects on your website.

/**
* Filter to redirect a user to a specific page after login.
*
* @return [URL] login URL with page slug on which it will be redirected after login
*/
add_filter( 'login_logout_menu_login', 'loginpress_login_menu_login_redirect' );
function loginpress_login_menu_login_redirect() {
  return wp_login_url( '/hello-world' );
}

Note: This filter works only when a user clicks on the login button or link from the Login Logout menu otherwise user will redirect to the default website page or dashboard.

Let’s see what happens when you’ll log in from the Login Logout Menu now:

You’ll be redirected to the “hello-world” page as given in the filter:

Logout button

3. Filter To Redirect the Users to a Custom Registration Page

If you want to redirect a new website visitor to a custom registration page that you have created on your website when a new user clicks on the registration button, then you have to use the given piece of filter code in your website theme's "functions.php" file and update the file.

Note: It’s recommended to use a child theme to edit the functions.php file instead of the parent theme. There are chances to lose the modified code when you update your theme. It might cause some adverse effects on your website.

/**
* Filter to redirect a user to a custom register page
*
* @return [URL] custom register page URL
*/
add_filter( 'login_logout_menu_register', 'loginpress_login_menu_register_redirect' );
function loginpress_login_menu_register_redirect() {
  return home_url( '/register' );
}

Let’s see what happens when you’ll click on the registration button now:

You’ll be redirected to a custom registration page as given in the filter:

4. Add/Modify Login Logout Menu Custom Username Text

If you want to add a custom Username text in Login Logout Menu, you must add the following code into your website theme's "functions.php" and update the file.

Note: It’s recommended to use a child theme to edit the functions.php file instead of the parent theme. There are chances to lose the modified code when you update your theme. It might cause some adverse effects on your website.

Note: Change the “Welcome” to your own text. This text will be appended before the username link.

/**
* Filter to Change the user profile link text
*
* @param [String] $user_name The name of the user who is logged in
*
* @return [string] Custom String and the username
*/
add_filter( 'login_logout_menu_username', 'custom_loginpress_login_logout_menu_username' );
function custom_loginpress_login_logout_menu_username( $user_name ) {
  return 'Welcome  ' . $user_name;
}

5. Filter To Redirect The User To Their Profile Page

If you are using any of these platforms in your WordPress website (Buddyboss, BuddyPress, and WooCommerce) and want to redirect the user to their profile page instead of the WordPress dashboard. You have to insert the given code below into your website theme's "functions.php" and update the file.

Note: It’s recommended to use a child theme to edit the functions.php file instead of the parent theme. There are chances to lose the modified code when you update your theme. It might cause some adverse effects on your website.

For BuddyPress

/**
* Filter to Change the user profile redirect URL
*
* @return [string] Custom link to user profile page
*
*/
add_filter( 'login_logout_menu_profile', 'loginpress_login_logout_menu_profile_link' );
function loginpress_login_logout_menu_profile_link( ) {
  //If BuddyPress is activated then go to its User profile page.
  if ( function_exists( 'bp_core_get_user_domain' ) ) {
     $url = bp_core_get_user_domain( get_current_user_id() );
  }
  return $url;
}

For BuddyBoss

/**
* Filter to Change the user profile redirect URL
*
* @return [string] Custom link to user profile page
*
*/
add_filter( 'login_logout_menu_profile', 'loginpress_login_logout_menu_profile_link' );
function loginpress_login_logout_menu_profile_link( ) {
  //If BuddyBoss is activated then go to its User profile page.
  if ( function_exists( 'bp_core_get_user_domain' ) ) {
     $url = bbp_get_user_profile_url( get_current_user_id() );
  }
  return $url;
}

For WooCommerce

/**
* Filter to Change the user profile redirect URL
*
* @return [string] Custom link to a user profile page
*
*/
add_filter( 'login_logout_menu_profile', 'loginpress_login_logout_menu_profile_link' );
function loginpress_login_logout_menu_profile_link( ) {
  //If WooCommerce is activated then go to its User profile page.
  if ( function_exists( 'bp_core_get_user_domain' ) ) {
    $url = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) );
  }
  return $url;
}

6. Filter To Change The User Profile Redirect URL

If you are using any of these platforms in your WordPress website (Buddyboss, BuddyPress, and WooCommerce). If you want to change the user profile redirect URL [Custom URL], then you have to use the following code in your website theme's "functions.php" file and update your file.

Note: It’s recommended to use a child theme to edit the functions.php file instead of the parent theme. There are chances to lose the modified code when you update your theme. It might cause some adverse effects on your website.

For BuddyPress

/**
* Filter to Change the user redirect URL
*
* @return [string] Custom link to user profile page
*
*/
add_filter( 'login_logout_menu_username_url', 'loginpress_login_logout_menu_user_link' );
function loginpress_login_logout_menu_user_link( ) {
// If BuddyPress is activated then go to its User profile page.
  if ( function_exists( 'bp_core_get_user_domain' ) ) {
     $url = bp_core_get_user_domain( get_current_user_id() );
  }
 return $url;
}

For BuddyBoss

/**
* Filter to Change the user redirect URL
*
* @return [string] Custom link to user profile page
*
*/
add_filter( 'login_logout_menu_username_url', 'loginpress_login_logout_menu_user_link' );
function loginpress_login_logout_menu_user_link( ) {
// If BuddyPress is activated then go to its User profile page.
  if ( function_exists( 'bp_core_get_user_domain' ) ) {
    $url = bbp_get_user_profile_url( get_current_user_id() );
}
return $url;
}

For WooCommerce

/**
* Filter to Change the user redirect URL
*
* @return [string] Custom link to user profile page
*
*/
add_filter( 'login_logout_menu_username_url', 'loginpress_login_logout_menu_user_link' );
function loginpress_login_logout_menu_user_link( ) {
// If BuddyPress is activated then go to its User profile page.
  if ( function_exists( 'bp_core_get_user_domain' ) ) {
    $url = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) );
}
return $url;
}

That’s it. We hope you now understand how you can add the Login Logout Menu Filter to your WordPress site. 

If you have any doubts or questions related to this matter, please don’t hesitate to contact our support team.

Still stuck? How can we help?

Updated on January 16, 2024

Documentation
LoginPress Support
triangular shape yellowish icon

Frequently Asked Questions (FAQs)

These FAQs answer the most common questions about our WordPress custom login page plugin.

three shapes icon

Where can I get support for LoginPress?

If you need help with LoginPress, you can contact us here. We’ll be happy to answer any questions about the plugin.

Do you have an affiliate program?

Yes, we have an affiliate program that you can sign up for here. As an affiliate, you’ll earn a commission on every sale you refer to us.

Do you offer refunds?

Yes, we offer a 14-day money-back guarantee on all of our plans. If you’re unsatisfied with LoginPress, simply contact us within 14 days of your purchase, and we’ll process a refund.

Can I upgrade my license after my initial purchase?

Yes, you can upgrade your LoginPress license at any time. Simply log into your account and go to the My Downloads page. From here, you can upgrade your license and download the latest version of the plugin.

Will LoginPress slow down my website?

No, LoginPress will not slow down your website. The plugin is lightweight and only loads the necessary files when someone tries to access your login page.

three shapes icon

If you Still have Questions?

Get In Touch