links - how redirect users to custom login page when user comment must “login to reply” is clicked?

admin2025-01-07  5

I am building my website on Wordpress and I have created my custom login page.But for a post when an user comments and other nonlogged see the comment with along with a line down "Login to reply".And when the user clicks on that"Login" from "Login to reply" it redirects to wp-login.php.So how to redirect users to custom login page when "login to reply" for a post is clicked on wordpress instead of wp-login.php.

I am building my website on Wordpress and I have created my custom login page.But for a post when an user comments and other nonlogged see the comment with along with a line down "Login to reply".And when the user clicks on that"Login" from "Login to reply" it redirects to wp-login.php.So how to redirect users to custom login page when "login to reply" for a post is clicked on wordpress instead of wp-login.php.

Share Improve this question asked Jan 6, 2018 at 6:39 Muhammad ShahzebMuhammad Shahzeb 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

Try using this in your functions.php file or in a plugin file-

add_filter( 'login_url', 'wpse_290288_custom_login_url', 10, 3 );
function wpse_290288_custom_login_url( $login_url, $redirect, $force_reauth ) {
    $login_page_id = 123; // ID of your custom login page
    return get_permalink( $login_page_id );
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736265093a1019.html

最新回复(0)