Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/08/2011 02:15:22 AM (13 years ago)
Author:
johnjamesjacoby
Message:

Port user active/status functions from bbPress 2. Deprecate old _core_ functions into 1.6.php as wrappers. See #3739.

File:
1 edited

Legend:

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

    r5302 r5305  
    494494 * @return bool True if spammer, False if not.
    495495 */
    496 function bp_core_is_user_spammer( $user_id = 0 ) {
     496function bp_is_user_spammer( $user_id = 0 ) {
    497497    global $wpdb;
    498498
     
    522522    }
    523523
    524     return apply_filters( 'bp_core_is_user_spammer', (bool) $is_spammer );
     524    return apply_filters( 'bp_is_user_spammer', (bool) $is_spammer );
    525525}
    526526
     
    532532 * @return bool True if deleted, False if not.
    533533 */
    534 function bp_core_is_user_deleted( $user_id = 0 ) {
     534function bp_is_user_deleted( $user_id = 0 ) {
    535535    global $wpdb;
    536536
     
    561561    }
    562562
    563     return apply_filters( 'bp_core_is_user_deleted', (bool) $is_deleted );
     563    return apply_filters( 'bp_is_user_deleted', (bool) $is_deleted );
     564}
     565
     566/**
     567 * Checks if user is active
     568 *
     569 * @since BuddyPress (1.6)
     570 *
     571 * @uses is_user_logged_in() To check if user is logged in
     572 * @uses bbp_get_displayed_user_id() To get current user ID
     573 * @uses bbp_is_user_spammer() To check if user is spammer
     574 * @uses bbp_is_user_deleted() To check if user is deleted
     575 *
     576 * @param int $user_id The user ID to check
     577 * @return bool True if public, false if not
     578 */
     579function bp_is_user_active( $user_id = 0 ) {
     580
     581    // Default to current user
     582    if ( empty( $user_id ) && is_user_logged_in() )
     583        $user_id = bp_loggedin_user_id();
     584
     585    // No user to check
     586    if ( empty( $user_id ) )
     587        return false;
     588
     589    // Check spam
     590    if ( bp_is_user_spammer( $user_id ) )
     591        return false;
     592
     593    // Check deleted
     594    if ( bp_is_user_deleted( $user_id ) )
     595        return false;
     596
     597    // Assume true if not spam or deleted
     598    return true;
     599}
     600
     601/**
     602 * Checks if user is not active.
     603 *
     604 * @since BuddyPress (1.6)
     605 *
     606 * @uses is_user_logged_in() To check if user is logged in
     607 * @uses bp_get_displayed_user_id() To get current user ID
     608 * @uses bp_is_user_active() To check if user is active
     609 *
     610 * @param int $user_id The user ID to check
     611 * @return bool True if inactive, false if active
     612 */
     613function bp_is_user_inactive( $user_id = 0 ) {
     614
     615    // Default to current user
     616    if ( empty( $user_id ) && is_user_logged_in() )
     617        $user_id = bp_loggedin_user_id();
     618
     619    // No user to check
     620    if ( empty( $user_id ) )
     621        return false;
     622
     623    // Return the inverse of active
     624    return !bp_is_user_active( $user_id );
    564625}
    565626
Note: See TracChangeset for help on using the changeset viewer.