I get this code to create a redirection after login. I see no error but it doesn't work. No errors, it just do nothing at all.

I added this code to functions.php in my child theme.


function redirect_admin(){
    die; // You have to die here

You can use the login_redirect hook.

function redirect_admin( $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_to = WP_HOME.'/quote-list/'; // Your redirect URL

    return $redirect_to;

add_filter( 'login_redirect', 'redirect_admin', 10, 3 );

Example taken from WordPress Codex

Also is_admin() does not check if the user is an administrator but if the administration panel is being displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.