Title: Error when adding reviews
Last modified: August 6, 2024

---

# Error when adding reviews

 *  Resolved [Slavek](https://wordpress.org/support/users/jackoneill/)
 * (@jackoneill)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/error-when-adding-reviews/)
 * Students can’t add reviews, there is an error “Something went wrong”. It doesn’t
   matter if the course was completed or not. I, as an admin, was able to add a 
   review. How to fix it? [https://pasteboard.co/01IcfFTV8fyw.jpg](https://pasteboard.co/01IcfFTV8fyw.jpg)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Slavek](https://wordpress.org/support/users/jackoneill/)
 * (@jackoneill)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/error-when-adding-reviews/#post-17937251)
 * I found the issue. I use the following code to deny access to wp admin dashboard
   to subscribers, and because of that, admin-ajax.php is returning 302. So how 
   to deny acces to wp-admin for subscribers and allow them adding reviews?
 *     ```wp-block-code
       function redirect_subscriber_to_frontend() {    $current_user = wp_get_current_user();    if (count($current_user->roles) == 1 && $current_user->roles[0] == 'subscriber') {        wp_redirect(site_url('/dashboard/'));        exit;    }}add_action('admin_init', 'redirect_subscriber_to_frontend');
       ```
   
 *  [Nafiz](https://wordpress.org/support/users/urnafiz/)
 * (@urnafiz)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/error-when-adding-reviews/#post-17937895)
 * Hello [@jackoneill](https://wordpress.org/support/users/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:
 *     ```wp-block-code
       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

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Error when adding reviews’ is closed to new replies.

 * ![](https://ps.w.org/tutor/assets/icon-256x256.gif?rev=3193875)
 * [Tutor LMS - eLearning and online course solution](https://wordpress.org/plugins/tutor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tutor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tutor/)
 * [Active Topics](https://wordpress.org/support/plugin/tutor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tutor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tutor/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Nafiz](https://wordpress.org/support/users/urnafiz/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/error-when-adding-reviews/#post-17937895)
 * Status: resolved