How to allow only registered users to enter a review

18.4.1. How to allow only registered users to enter a review

If you want only your registered users to be able to enter a review, you can achieve it with the following simple change:

Edit the modules/Reviews/index.php file and find the write_review() function:

function write_review() {
    global $admin, $sitename, $user, $cookie, $prefix, $user_prefix, 
    $currentlang, $multilingual, $dbi, $module_name;
    include ('header.php');
    OpenTable();

Add the following check after the call to OpenTable():

    if (!is_user($user)) {
        echo "You need to be 
        <a href=\"account.html\">logged in</a> or 
        <a href=\"account-new_user.html\">become a member</a> 
        to submit reviews.";
    } else {

This check will only allow registered users to continue with a review, while pointing others to the login or register page. Of course, the IF statement has to be closed - just put a } at the end of the function, as shown below:

    CloseTable();
    include ("footer.php");
}
}

Unregistered users will be able to view reviews, but only site members will be able to submit new ones.

Tip Tip
 

This simple check can be used to restrict access to registered users in any module that does not offer this functionality, not only in Reviews.

 

Site Info v2.2.2

Last SeenLast Seen
Server TrafficServer Traffic
  • Total: 339,150,750
  • Today: 30,890
Server InfoServer Info
  • Oct 21, 2017
  • 09:02 am PDT
 
 

Daily Inspiration