WordPress.org

Ready to get started?Download WordPress

Forums

Way to modify "user must have previously approved comment" (3 posts)

  1. citeewurkor
    Member
    Posted 9 years ago #

    hello,
    Is there a way to have a user have multiple comments approved before their comments are approved automatically?

    for example, a user that has never made a comment on my site must get three "approved" comments, before being allowed to have comments automatically posted.

    Thanks for any help or suggestions.

    I use Spam Karma 2 and have the moderation plugin installed.

  2. Kafkaesqui

    Posted 9 years ago #

    "Is there a way to have a user have multiple comments approved before their comments are approved automatically?"

    Yes, but you'll have to perform some source editing to accomplish this.

    In comment-functions.php (wp-includes/), go all the way to the end of the document, to where you'll find this section:

    // Comment whitelisting:

    Look here for the following line:

    1.5.x:
    if ( 1 == $ok_to_comment && false === strpos( $email, get_settings('moderation_keys')) )

    2.0:
    if ( ( 1 == $ok_to_comment ) && ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )

    You want to add a new query line just above it, and modify the line(s) like so:

    1.5.x:
    $count_approved = count($wpdb->get_col("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1'"));
    if ( (1 == $ok_to_comment && 3 <= $count_approved) && false === strpos( $email, get_settings('moderation_keys')) )

    2.0:
    $count_approved = count($wpdb->get_col("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1'"));
    if ( ( 1 == $ok_to_comment && 3 <= $count_approved ) && ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )

    Hacker note: Back up any files before editing them, and comment your changes for future reference.

  3. citeewurkor
    Member
    Posted 9 years ago #

    Excellent! That is very good. Appreciate it!

Topic Closed

This topic has been closed to new replies.

About this Topic