• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / Akismet::get_user_comments_approved() –

You appear to be a bot. Output may be restricted

Description

Usage

Akismet::get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url );

Parameters

$user_id
( mixed ) required –
$comment_author_email
( mixed ) required –
$comment_author
( mixed ) required –
$comment_author_url
( mixed ) required –

Returns

void

Source

File name: akismet/class.akismet.php
Lines:

1 to 38 of 38
  public static function get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
    global $wpdb;

    
/**
 * Which comment types should be ignored when counting a user's approved comments?
 *
 * Some plugins add entries to the comments table that are not actual
 * comments that could have been checked by Akismet. Allow these comments
 * to be excluded from the "approved comment count" query in order to
 * avoid artificially inflating the approved comment count.
 *
 * @param array $comment_types An array of comment types that won't be considered
 *                             when counting a user's approved comments.
 *
 * @since 4.2.2
 */
    $excluded_comment_types = apply_filters( 'akismet_excluded_comment_types', array() );

    $comment_type_where = '';

    if ( is_array( $excluded_comment_types ) && ! empty( $excluded_comment_types ) ) {
      $excluded_comment_types = array_unique( $excluded_comment_types );

      foreach ( $excluded_comment_types as $excluded_comment_type ) {
        $comment_type_where .= $wpdb->prepare( ' AND comment_type <> %s ', $excluded_comment_type );
      }
    }

    if ( ! empty( $user_id ) ) {
      return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE user_id = %d AND comment_approved = 1" . $comment_type_where, $user_id ) );
    }

    if ( ! empty( $comment_author_email ) ) {
      return (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->comments} WHERE comment_author_email = %s AND comment_author = %s AND comment_author_url = %s AND comment_approved = 1" . $comment_type_where, $comment_author_email, $comment_author, $comment_author_url ) );
    }

    return 0;
  }
 

 View on GitHub View on Trac

Published: 19th December 2019 | Last updated: 25th January 2022

Primary Sidebar

Information

Function name: Akismet::get_user_comments_approved
Class ref: Akismet
Plugin ref: Akismet
Version: 5.0.1
Sourcefile: class.akismet.php
File ref: class.akismet.php
Deprecated?: No
API Letters: A,C,G,U

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites