0

I want to redirect the signin and signout link from comment form in Wordpress.

I am using a plugin to register users from the front-end; there I have two pages: sign-in and register. When someone registers from this page and logs in from this page, then its working fine.

But when someone is going to give a comment to a post and is not logged in, then a link shows directing the user to login. Upon clicking this link it goes to wp-login.php, but I want to redirect this link to my sign-in page and after sign in the sign out link should go to this page as well.

How can I do this?

1
  • hi am add this function in my function.php but it give the error at wp-login.php Warning: Missing argument 2 for my_login_redirect() in /var/www/html/universis/dev/wp-content/themes/uniersis/functions.php on line 672 Warning: Missing argument 3 for my_login_redirect() in /var/www/html/universis/dev/wp-content/themes/uniersis/functions.php on line 672 actually i want to edit wp-includes/comment-template.php function namely comment_form. when i am click looged-in link shows at comment form its go to at my sign-in page not wp-login.php
    – rekha
    May 1, 2013 at 5:41

1 Answer 1

2

Use the filter login_redirect to redirect users to a page of your choice after login, and logout_url to redirect them after logging out.

An example would be the following:

function my_login_redirect( $url, $request, $user ){

     // Redirect non administrator users to a custom url.
     // Administrator gets redirected to default url 
     if( !current_user_can( 'administrator' ) )
         return 'my-custom-url';
     else return $url;

}

add_filter('login_redirect', 'my_login_redirect');
3
  • hi am add this function in my function.php but it give the error at wp-login.php Warning: Missing argument 2 for my_login_redirect() in /var/www/html/universis/dev/wp-content/themes/uniersis/functions.php on line 672 Warning: Missing argument 3 for my_login_redirect() in /var/www/html/universis/dev/wp-content/themes/uniersis/functions.php on line 672
    – rekha
    May 1, 2013 at 5:23
  • actually i want to edit wp-includes/comment-template.php function namely comment_form. when i am click looged-in link shows at comment form its go to at my sign-in page not wp-login.php
    – rekha
    May 1, 2013 at 5:40
  • Uhm… alright, what's your signin page? May 1, 2013 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.