Reply To: Login redirect for Admins

Home Forums User Registration Login redirect for Admins Reply To: Login redirect for Admins

#3489

sanjeev3
Member

Hello Montiel,

Thank you for the clarification. You want to redirect to dashboard for the admins and users with other roles to the my account section while logging in from the user registration login form or my account form? Right? Here is the working code.

function ur_admin_default_page(  $redirect, $user ) {

	$roles = isset( $user->roles ) ? $user->roles : array();
	if( in_array( 'administrator', $roles ) ) {
		return admin_url();
	}
	else {
		return $redirect;
	}
}

add_filter( 'user_registration_login_redirect', 'ur_admin_default_page', 10, 2 );

Hope this helps! Also, we really appreciate your review to our plugin, https://wordpress.org/support/plugin/user-registration/reviews/?filter=5

Thank you for your support!
WPEverest