Change Redirection after login and logout on frontend – wordpress

Hi Friend!! Sorry I was little bit busy with some tasks so I was not able to give time to post new stuffs. Recently I got one requirement like client wants login and logout in fronend. After that client also wants that after login user can be redirect to his account page. And After logout it must be redirect to homepage.

I know there are many plugins in market but by this plugins if admin wants to login then admin also have to login from frontend.

So after long research on it I found some code which needs to added in theme’s functions.php file.

Below is the whole snippet of code which you have to just copy and page in functions.php.

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

if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) && $url != '' && $url !='' ) {
 $url = home_url('');
 return $url;

add_filter('login_redirect', 'my_login_redirect', 10, 3 );
function go_home(){
 wp_redirect( home_url() );

In First part, you can see that there is one condition in which wp-admin is used. By this condition this redirection will not apply for admin.

By second part, logout redirection is applied.

I hope you like my post and if any problem then please comment on this post.

  • سئو

    tanks admin

  • test

    oh i see