Viewing 6 replies - 1 through 6 (of 6 total)
  • Here’s what I did. It checks if the user is an admin or an author and, if they are, they get redirected to the dashboard. Otherwise, they get redirected to the a ‘contribute’ page. This should be added to your themes functions.php file. You should be able to modify it fairly easily to do what you want.

    /** Login Redirect **/
    add_filter("login_redirect", "my_login_redirect", 10, 3);
    function my_login_redirect( $redirect_to, $request, $user ){
        //is there a user to check?
        if( is_array( $user->roles ) ) {
            //check for admins
            if( in_array( "administrator", $user->roles ) || in_array( "editor", $user->roles ) ||  in_array( "author", $user->roles ) ) {
                // redirect them to the default place
                return 'https://someurl.com/wp-admin/';
            } else {
                return 'https://someurl.com/contribute/';
            }
        }
    }

    I’m not sure I understand this, but I’m in the same basic boat as ifrodia, in that I need to re-direct the users to the main site, not to wp-admin after logging in.

    How exactly is this accomplished through the WP User Frontend plugin?

    gpspake

    (@gpspake)

    @tommwiseman

    WPUF doesn’t do this automatically.

    The function my_login_redirect() above says ‘If the user is an admin, redirect them to ‘https://someurl.com/wp-admin/’, otherwise, redirect them to return ‘https://someurl.com/contribute/.
    Then it gets hooked in to the wordpress function ‘login_redirect()’

    you have to add that code above in your theme’s functions.php file and replace ‘https://someurl.com/wp-admin/’ and ‘https://someurl.com/contribute/’ to whatever page you want people to get redirected to.

    https://codex.www.ads-software.com/Functions_File_Explained

    TomMWiseman

    (@tommwiseman)

    Yeah, I figured that out after re-reading this post a few times.

    Many thanks though.

    professor99

    (@professor99)

    Stay tuned. Redirects to url are included in the next developement release in a day or two or just edit the developement release as stated near the current end of the development thread above

    I tried using the above code ant nothing happened. I have changed the urls to go to the typical wp-admin and the home page if they do not have admin rights. The user that is logging in has an access level of “Subscriber” so shouldn’t this take them to the home page on the front end?

    If not, what role needs to be assigned to them in order for the code to defer them to the front end home page?

    Many thanks,
    Houston

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Redirect to frontend dashboard skip wp-admin’ is closed to new replies.