Is it possible to redirect a user once they login

Is it possible to redirect a user once they login to the “all pages” area of their site? This would need to work for each individual sub-site of the muti-site.

  • Anang
    • New Recruit

    Hi @jason

    I hope you don’t mind I jump in here :slight_smile:

    You need to add script in mu-plugins directory to made it work through multisite. Here’re the steps :

    1. Create mu-plugins folder in wp-content folder

    2. Create a new file called custom-redirect.php

    3. Put this code inside

    function my_login_redirect($redirect_to, $request, $user)
    return (is_array($user->roles) && in_array('administrator', $user->roles)) ? admin_url() : get_admin_url( get_current_blog_id(),'/edit.php?post_type=page');
    add_filter('login_redirect', 'my_login_redirect', 10, 3);

    4. Save the file

    5. Test your login.

    It will redirect non administrator users to view all page, and administrator to normal dashboard.

    Let me know if it’s worked :slight_smile:

    Best Regards

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.