WordPress.org

Support

Support » Plugins and Hacks » Registered users do not require comment moderation

Registered users do not require comment moderation

  • I’m looking for a plug-in that will allow a registered user (subscriber through author) to post comments while logged in without requiring comment moderation. If not logged in, comments require moderation.

    As far as I can tell, there are no settings that expressly permit registered subscribers (only) to comment freely.

    Your ideas and help are appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
  • Justin Tadlock

    @greenshady

    WordPress God

    Something like this should work. Drop it in your theme’s functions.php file:

    add_action( 'preprocess_comment', 'my_check_comment', 1 );
    
    function my_check_comment( $commentdata ) {
    
    	/* Get the user ID of the comment author. */
    	$user_id = absint( $commentdata['user_ID'] );
    
    	/* If comment author is a registered user, approve the comment. */
    	if ( 0 < $user_id )
    		add_filter( 'pre_comment_approved', 'my_approve_comment' );
    	else
    		add_filter( 'pre_comment_approved', 'my_moderate_comment' );
    
    	return $commentdata;
    }
    
    function my_approve_comment( $approved ) {
    	$approved = 1;
    	return $approved;
    }
    
    function my_moderate_comment( $approved ) {
    	if ( 'spam' !== $approved )
    		$approved = 0;
    	return $approved;
    }

    hey, that worked and I appreciate it greatly!

    eastwoodarts

    @eastwoodarts

    works great. many thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Registered users do not require comment moderation’ is closed to new replies.
Skip to toolbar