How to Redirect to custom page after logged in and comment

Shortlink:

Hello Everyone, Today I will teach you how to redirect custom page after logged in or how to redirect custom page after any people commented on your website, it’s very easy just need write one function for redirect after logged in any user and one function for redirect after submit comment any people. so now we’ll go to work.

just copy below codes and past in your functions.php file on your activated theme [For logged in user redirect] you can change function name, but don’t change filter function (‘login_redirect’)

function login_redirect_user( $redirect_to, $request, $user ){ 
return home_url('custom-page-url.extension'); 
//Custom page url extension where want redirect 
} 
add_filter( 'login_redirect', 'login_redirect_user', 10, 3 );

Now if you want to redirect people after submit comment on your website then just copy below codes and past in your functions.php file on your activated theme. you can change function name, but don’t change filter name ‘comment_post_redirect’

 

 

function comment_redirect($location)
{
return 'http://www.yoursite.com/thanks.html';
}

add_filter('comment_post_redirect', 'comment_redirect');

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!




%d bloggers like this: