MyListing Club

Hold All Reviews for Moderation and Notify Website Admin

Building better MyListing websites. One code snippet at a time.

Overview

The Hold All Reviews for Moderation and Notify Website Admin snippet allows for greater control of the Listing reviews being posted to a MyListing website. 

When a user posts a review for a Listing, the review will be held in the system, the website admin will be notified via email, and the review will be released when/if the website admin approves it.

Implementation

  1. Grab the code snippet.
  2. Follow the provided instructions.
  3. Save your changes.
				
					//// INSTRUCTIONS: 
//// Copy and paste the code snippet below into the child theme's functions.php file.
//// You can edit the functions.php file from your WordPress dashboard (Appearance > Theme Editor) or via FTP.

--------------------------- CODE SNIPPET IS BELOW THIS LINE --------------------------- 

// HOLD ALL REVIEWS FOR MODERATION AND NOTIFY WEBSITE ADMIN
add_filter( 'pre_comment_approved', function( $commentstatus, $commentdata ) {
    $commentstatus = 0;
    return $commentstatus;
}, 10, 2 );

add_filter( 'wp_update_comment_data', function( $data, $comment, $commentarr ) {
 
    if ( isset( $data['comment_approved'] ) ) {
        $data['comment_approved'] = 0;
    } 
    return $data; 
}, 99, 3 );