Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Quirk redirect after login

Discussion in 'Misc WordPress Requests' started by belly05, Jan 12, 2018.

  1. belly05


    Reply To: Quirk redirect after login, by belly05

    Hi fibbo8 –

    If I’m understanding you correctly it looks like you are really close to getting this to work. You can go about this redirect many different ways (including finding a plugin that would help you set up the redirect). However, a php snippet is below that should work for you:

    * WordPress function for redirecting users on login based on user role
    function my_login_redirect( $url, $request, $user ){
    if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
    if( $user->has_cap( 'administrator' ) ) {
    $url = admin_url();
    } else {
    $url = home_url('/members-only/');
    return $url;
    add_filter('login_redirect', 'my_login_redirect', 10, 3 );

    **Please note this snippet above takes any user that is not an administrator and redirects them to the front end page /members-only/. You can change the /members-only/ link to whatever link you need.

    Reply To: Quirk redirect after login

Share This Page

Monarch Social Sharing Plugin