Sunday, May 26, 2013

Auto Redirect after login

Auto Redirect after login

In multisite this code redirect users (authors) to /wp-admin/post-new.php after the login ....but also redirects me (super admin) how can I prevent this?
function primary_login_redirect( $redirect_to, $request_redirect_to, $user )
{
    if ($user->ID != 0) {
        $user_info = get_userdata($user->ID);
        if ($user_info->primary_blog) {
            $primary_url = get_blogaddress_by_id($user_info->primary_blog) . 'wp-admin/post-new.php';
            if ($primary_url) {
                wp_redirect($primary_url);
                die();
            }
        }
    }
    return $redirect_to;
}
add_filter('login_redirect','primary_login_redirect', 100, 3);

No comments:

Post a Comment