Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #61746, comment 1


Ignore:
Timestamp:
07/24/2024 07:29:05 PM (6 weeks ago)
Author:
dipakparmar2007
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #61746, comment 1

    initial v1  
    88
    99function custom_login_redirect($redirect_to, $request, $user) {
    10     // Check if the user object is a WP_User instance
    11     if (isset($user->roles) && is_array($user->roles)) {
    12         // Check user role and redirect accordingly
    13         if (in_array('administrator', $user->roles)) {
    14             // Redirect administrators to the admin dashboard
    15             return home_url('/dashboard/');
    16         } else {
    17             // Redirect other users to a specific page
    18             return home_url('/dashboard/'); // Change /custom-page to your desired page
    19         }
    20     } else {
    21         // Default redirect
     10   
    2211        return home_url('/dashboard/');
    23     }
     12
    2413}
    2514