Login Logout Menu Filters

Filter To Redirect A User To A Specific Page After Logout

If you want to redirect a user after log out to a specific page that you have created on your website. Simply you have to add the given piece of code into your Child's Theme file "functions.php" and save the code.
/**
 * 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' );
}

 Filter To Add Redirect After Successful Login

If you want to redirect your website user to another specific page that you have created on your website instead of a site dashboard page then you have to add the following piece of code in your Child's Theme file "functions.php" and save the code.
/**
* 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.

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 click on the registration button then you have to use the given piece of filter code in your Child's Theme file "functions.php" and update the file.


/**
* 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' );
}

Add/Modify Login Logout Menu Custom Username Text

If you want to change the Username text in Login Logout Menu on your WordPress website then you have to insert the following piece of code into your Child's Theme file "functions.php" and update the file.

/**
* Filter to Change the user profile link text
*
* @param [String] $user_name The name of the user which 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;
}

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 you want to redirect the user to their profile page instead of the WordPress dashboard, then you have to insert the given code below into your Child's Theme file "functions.php" and update the file.

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 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;
}

Filter To Change The User Profile Redirect URL

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

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;
}

Check our complete guide on how to add social login buttons with LoginPress social login shortcode on your eCommerce or any other website/blog.

Still stuck? How can we help?

Updated on September 13, 2021

Documentation
LoginPress Support
triangular shape yellowish icon

Frequently Asked Questions

Try to find your solution with the frequently asked questions about or services.

three shapes icon

Is LoginPress WPML Compatible?

LoginPress is fully supported with multilingual. LoginPress is also compatible with WPML Plugin, which means you can easily translate your login page with WPML plugin according to the given translation options in the WPML plugin.

Is LoginPress translation ready?

Yes, LoginPress has full translation and localization support via the LoginPress textdomain. All .mo and .po translation files should go into the languages folder in the base of the plugin.

Is coding skills needed to use LoginPress?

No, It is very easy to setup. Just plug and play. Have fun!

How to Install or Use LoginPress Pro?

Step-by-step instructions on How to Upgrade from existing Free version to Pro
1. You have installed and set up the Free version already.
2. Upload the Pro version.
3. Pro features will be enabled automatically.
4. You don’t need to set up Free version options again.
5. Setup Pro features like Google fonts, Google reCaptcha, Choose themes, etc.

Where is my license key?

License key is the Order ID which looks like in this format.
WHI150807-1234-12345
You can find it in the email Sales Receipt.

three shapes icon

If you Still have Questions?

Get In Touch