Hello @jackoneill,
Thank you for reaching out and providing detailed information about the issue you’re experiencing.
The problem arises because your current code redirects all subscribers away from any admin-related pages, including the admin-ajax.php file, which is necessary for certain frontend operations like adding reviews.
To resolve this, please remove the old code and add the following code to your theme’s functions.php file:
function redirect_subscribers_to_dashboard() {
// Check if the current user is logged in
if (is_user_logged_in()) {
$user = wp_get_current_user();
// Check if the current user has the 'subscriber' role
if (in_array('subscriber', (array) $user->roles)) {
// Get the current admin URL
$current_url = $_SERVER['REQUEST_URI'];
// Check if the current URL is an admin page and not an AJAX request
if (strpos($current_url, '/wp-admin') !== false && strpos($current_url, 'admin-ajax.php') === false) {
// Redirect to the Tutor LMS dashboard
wp_redirect(home_url('/dashboard/'));
exit;
}
}
}
}
add_action('admin_init', 'redirect_subscribers_to_dashboard');
After adding this code, subscribers will be able to add reviews without being redirected.
If you continue to experience issues or have any other questions, please feel free to let us know. We are here to help!
Best regards,
Mohammad Nafiz