<?php
// Redirect users after login based on their roles
function custom_mepr_login_redirect_url($url, $user) {
// Check if the user object is valid
if (isset($user->roles) && is_array($user->roles)) {
// Roles that should be redirected to the WordPress dashboard
$admin_roles = array('administrator', 'editor', 'author');
// Check if the user has any of the admin roles
if (array_intersect($admin_roles, $user->roles)) {
// Redirect to the WordPress dashboard
return admin_url();
}
// Default redirect
return $url;
add_filter('mepr-process-login-redirect-url', 'custom_mepr_login_redirect_url', 11, 2);