Title: redirection login
Last modified: March 13, 2023

---

# redirection login

 *  Resolved [christ59620](https://wordpress.org/support/users/christ59620/)
 * (@christ59620)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/redirection-login/)
 * Regarding my login page, my registered users are directed to their profile page,
   whereas I would like them to arrive on the main page of the site.
   I read the 
   redirection code doc but I don’t know where to paste this code.
 * thank you

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Support [Muhammad Arslan](https://wordpress.org/support/users/wparslan/)
 * (@wparslan)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/redirection-login/#post-16565673)
 * Hey [@christ59620](https://wordpress.org/support/users/christ59620/)
 * May i know which do are you referring here?
 * Do know, You have to copy and paste the code in the functions.php file of your
   child theme.
 * If you need any assistance do let us know.
 * Have a nice day!
 *  Thread Starter [christ59620](https://wordpress.org/support/users/christ59620/)
 * (@christ59620)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/redirection-login/#post-16573466)
 * Good morning,
 * Thank you for your help.
 * I was referring to this code addition.
 * [https://developer.wordpress.org/reference/hooks/login_redirect/](https://developer.wordpress.org/reference/hooks/login_redirect/)
 * Not being a child code of the theme, I will refer the addition to each modification
   of the theme (newspaper).
 * Thanks again.
 *  Plugin Support [Muhammad Arslan](https://wordpress.org/support/users/wparslan/)
 * (@wparslan)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/redirection-login/#post-16590622)
 * Hey [@christ59620](https://wordpress.org/support/users/christ59620/)
 * You can use the following piece of code, It will redirect the admin user to the
   backend and all other user roles to the home page of the site.
 *     ```wp-block-code
       /**
        * Redirect user after successful login.
        *
        * @param string $redirect_to URL to redirect to.
        * @param string $request URL the user is coming from.
        * @param object $user Logged user's data.
        * @return string
        */
       function login_cust_login_redirect( $redirect_to, $request, $user ) {
       	//is there a user to check?
       	if ( isset( $user->roles ) && is_array( $user->roles ) ) {
       		//check for admins
       		if ( in_array( 'administrator', $user->roles ) ) {
       			// redirect them to the default place
       			return $redirect_to;
       		} else {
       			return home_url();
       		}
       	} else {
       		return $redirect_to;
       	}
       }
   
       add_filter( 'login_redirect', 'login_cust_login_redirect', 10, 3 );
       ```
   
 * If this doesn’t work for you, there might be some plugin or theme conflict which
   is also applying the redirection.
 * Do let us know if this works for you.
 * Have a nice day!
 *  Thread Starter [christ59620](https://wordpress.org/support/users/christ59620/)
 * (@christ59620)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/redirection-login/#post-16613032)
 * Thank you very much

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘redirection login’ is closed to new replies.

 * ![](https://ps.w.org/login-customizer/assets/icon-256x256.png?rev=2455454)
 * [Custom Login Page Customizer](https://wordpress.org/plugins/login-customizer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/login-customizer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/login-customizer/)
 * [Active Topics](https://wordpress.org/support/plugin/login-customizer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/login-customizer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/login-customizer/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [christ59620](https://wordpress.org/support/users/christ59620/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/redirection-login/#post-16613032)
 * Status: resolved