uo-redirect-login-page
Filters the login page URL used by the plugin before the redirect occurs.
add_filter( 'uo-redirect-login-page', $callback, 10, 1 );
Description
Fires when determining the login page URL for redirects. Developers can modify the `$login_page` parameter to change the destination URL, useful for custom login flows or specific redirect logic. This filter runs before the redirect action.
Usage
add_filter( 'uo-redirect-login-page', 'your_function_name', 10, 1 );
Parameters
-
$login_page(mixed) - This parameter contains the URL of the login page, which can be modified by the filter.
Return Value
The filtered value.
Examples
/**
* Customizes the login page URL for specific user roles.
*
* This function intercepts the login page URL filter and modifies it
* to redirect users with the 'subscriber' role to a custom login page.
*
* @param string $login_page The original login page URL.
* @return string The modified login page URL.
*/
add_filter( 'uo-redirect-login-page', function( $login_page ) {
// Check if the current user has the 'subscriber' role.
if ( current_user_can( 'subscriber' ) ) {
// If they are a subscriber, redirect them to a custom login page.
// Replace 'https://example.com/custom-subscriber-login/' with your actual custom login page URL.
return 'https://example.com/custom-subscriber-login/';
}
// If not a subscriber, return the original login page URL.
return $login_page;
}, 10, 1 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/classes/frontend-login-plus.php:2230
}
if ( 'lostpassword' === $http_request_action ) {
$login_page = add_query_arg( array( 'action' => $http_request_action ), $login_page );
}
// Allow modifications.
$login_page = apply_filters( 'uo-redirect-login-page', $login_page );
// Change the redirect from `301` to `302` to prevent aggressive caching of browser.
wp_safe_redirect( $login_page, 302 );
exit;
}