Skip to:
Content

BuddyPress.org

Changeset 6983


Ignore:
Timestamp:
05/01/2013 06:10:39 PM (7 years ago)
Author:
r-a-y
Message:

In bp_is_user_spammer(), if user is logged-in user or displayed user, use
the already-queried userdata.

Use bp_is_user_spammer() in bp_stop_live_spammer() function.

See #4814.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-functions.php

    r6978 r6983  
    655655        return false;
    656656
     657    $bp = buddypress();
     658
    657659    // Assume user is not spam
    658660    $is_spammer = false;
    659661
    660662    // Get user data
    661     $user = get_userdata( $user_id );
     663    switch ( $user_id ) {
     664        case bp_loggedin_user_id() :
     665            $user = $bp->loggedin_user->userdata;
     666            break;
     667
     668        case bp_displayed_user_id() :
     669            $user = $bp->displayed_user->userdata;
     670            break;
     671
     672        default :
     673            $user = get_userdata( $user_id );
     674            break;
     675    }
    662676
    663677    // No user found
     
    14321446 */
    14331447function bp_stop_live_spammer() {
    1434     $bp = buddypress();
    1435 
    14361448    // user isn't logged in, so stop!
    1437     if ( empty( $bp->loggedin_user ) ) {
     1449    if ( ! is_user_logged_in() ) {
    14381450        return;
    14391451    }
    14401452
    1441     // get logged-in userdata
    1442     $user = $bp->loggedin_user->userdata;
    1443 
    1444     // setup spammer boolean
    1445     $spammer = false;
    1446 
    1447     // multisite spammer
    1448     if ( ! empty( $user->spam ) ) {
    1449         $spammer = true;
    1450 
    1451     // single site spammer
    1452     } elseif ( $user->user_status == 1 ) {
    1453         $spammer = true;
    1454     }
    1455 
    14561453    // if spammer, kills access to the site
    1457     if ( $spammer ) {
     1454    if ( bp_is_user_spammer( bp_loggedin_user_id() ) ) {
    14581455        // the spammer will not be able to view any portion of the site whatsoever
    14591456        // this is a good detterent as the user cannot re-register to the site easily
Note: See TracChangeset for help on using the changeset viewer.