Skip to:
Content

bbPress.org

Changeset 6753


Ignore:
Timestamp:
12/16/2017 10:25:12 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Duplicates: check post_author argument instead of current user.

This change brings duplicate checking up to speed with flood and blacklist checks by preferring user_can() over current_user_can(), and plays a bit more friendly with anonymous author IDs.

Props r-a-y. Fixes #3186.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/common/functions.php

    r6742 r6753  
    611611function bbp_check_for_duplicate( $post_data = array() ) {
    612612
    613     // No duplicate checks for those who can throttle
    614     if ( current_user_can( 'throttle' ) ) {
    615         return true;
    616     }
    617 
    618613    // Parse arguments against default values
    619614    $r = bbp_parse_args( $post_data, array(
     
    626621    ), 'check_for_duplicate' );
    627622
     623    // No duplicate checks for those who can throttle
     624    if ( user_can( (int) $r['post_author'], 'throttle' ) ) {
     625        return true;
     626    }
     627
    628628    // Get the DB
    629629    $bbp_db = bbp_db();
     
    671671    $dupe   = apply_filters( 'bbp_check_for_duplicate_query', $query, $r );
    672672
     673    // Dupe found
    673674    if ( $bbp_db->get_var( $dupe ) ) {
    674675        do_action( 'bbp_check_for_duplicate_trigger', $post_data );
     
    676677    }
    677678
     679    // Dupe not found
    678680    return true;
    679681}
Note: See TracChangeset for help on using the changeset viewer.