Skip to:
Content

BuddyPress.org

Ticket #4814: 4814.01.patch

File 4814.01.patch, 1.7 KB (added by r-a-y, 8 years ago)
  • bp-members/bp-members-functions.php

    function bp_core_wpsignup_redirect() { 
    13981398        bp_core_redirect( bp_get_signup_page() );
    13991399}
    14001400add_action( 'bp_init', 'bp_core_wpsignup_redirect' );
     1401
     1402/**
     1403 * Stop a logged-in spammer from being able to access the site.
     1404 *
     1405 * When an admin marks a live user as a spammer, that user can still surf
     1406 * around and cause havoc on the site until that person is logged out.
     1407 *
     1408 * This code checks to see if a logged-in user is marked as a spammer.  If so,
     1409 * we kill access to the rest of the site.
     1410 *
     1411 * Runs on 'bp_init' at priority 5 so the members component globals are setup
     1412 * before we do our spammer checks.
     1413 *
     1414 * This is important as the $bp->loggedin_user object is setup at priority 4.
     1415 *
     1416 * @since BuddyPress (v1.x)
     1417 */
     1418function bp_stop_live_spammer() {
     1419        $bp = buddypress();
     1420
     1421        // user isn't logged in, so stop!
     1422        if ( empty( $bp->loggedin_user ) ) {
     1423                return;
     1424        }
     1425
     1426        // get logged-in userdata
     1427        $user = $bp->loggedin_user->userdata;
     1428
     1429        // setup spammer boolean
     1430        $spammer = false;
     1431
     1432        // multisite spammer
     1433        if ( ! empty( $user->spam ) ) {
     1434                $spammer = true;
     1435
     1436        // single site spammer
     1437        } elseif ( $user->user_status == 1 ) {
     1438                $spammer = true;
     1439        }
     1440
     1441        // if spammer, kills access to the site
     1442        if ( $spammer ) {
     1443                // the spammer will not be able to view any portion of the site whatsoever
     1444                // this is a good detterent as the user cannot re-register to the site easily
     1445                wp_die( __( '<strong>ERROR</strong>: Your account has been marked as a spammer.', 'buddypress' ) );
     1446                exit;
     1447        }
     1448}
     1449add_action( 'bp_init', 'bp_stop_live_spammer', 5 );