Reply To: Login redirect for Admins

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

#3516

Rodrigo Montiel
Participant

Hello sanjeev3,

Yes! That was what I needed. Thank you!
I just added the redirect to the account page for not admins, so now if a regular user logs in from the login page it also gets redirected to the Account page 🙂

function ur_admin_default_page(  $redirect, $user ) {

	$roles = isset( $user->roles ) ? $user->roles : array();
	if( in_array( 'administrator', $roles ) ) {
		return admin_url();
	}
	else {
        $redirect = get_permalink( ur_get_page_id( 'myaccount' ) );
		return $redirect;
	}
}
add_filter( 'user_registration_login_redirect', 'ur_admin_default_page', 10, 2 );

Thank you