Skip to:
Content

BuddyPress.org

Changeset 10322


Ignore:
Timestamp:
11/02/2015 01:58:52 AM (9 years ago)
Author:
tw2113
Message:

More documentation cleanup for the Members component.

See #6402.

Location:
trunk/src/bp-members
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/admin/bp-members-admin-classes.php

    r10248 r10322  
    11<?php
    22/**
    3  * BuddyPress Members List Classes
     3 * BuddyPress Members List Classes.
    44 *
    55 * @package BuddyPress
     
    8989     * @since 2.0.0
    9090     *
    91      * @uses WP_Users_List_Table::get_views() to get the users views
     91     * @uses WP_Users_List_Table::get_views() to get the users views.
    9292     */
    9393    public function get_views() {
    9494        $views = parent::get_views();
    9595
    96         // Remove the 'current' class from the 'All' link
     96        // Remove the 'current' class from the 'All' link.
    9797        $views['all']        = str_replace( 'class="current"', '', $views['all'] );
    9898        $views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', esc_url( add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) );
     
    109109     * @since 2.0.0
    110110     *
    111      * @param array $which
     111     * @param array $which Current table nav item.
    112112     */
    113113    public function extra_tablenav( $which ) {
     
    172172            $link = false;
    173173
    174             // Specific case when BuddyPress is not network activated
     174            // Specific case when BuddyPress is not network activated.
    175175            if ( is_multisite() && current_user_can( 'manage_network_users') ) {
    176176                $link = sprintf( '<a href="%1$s">%2$s</a>', esc_url( network_admin_url( 'settings.php'       ) ), esc_html__( 'Edit settings', 'buddypress' ) );
     
    206206        foreach ( $this->items as $userid => $signup_object ) {
    207207
    208             // Avoid a notice error appearing since 4.3.0
     208            // Avoid a notice error appearing since 4.3.0.
    209209            if ( isset( $signup_object->id ) ) {
    210210                $signup_object->ID = $signup_object->id;
     
    227227     * @param string      $role          Role to be assigned to user.
    228228     * @param int         $numposts      Numper of posts.
    229      *
    230      * @return string
     229     * @return void
    231230     */
    232231    public function single_row( $signup_object = null, $style = '', $role = '', $numposts = 0 ) {
     
    260259        $avatar = get_avatar( $signup_object->user_email, 32 );
    261260
    262         // Activation email link
     261        // Activation email link.
    263262        $email_link = add_query_arg(
    264263            array(
     
    270269        );
    271270
    272         // Activate link
     271        // Activate link.
    273272        $activate_link = add_query_arg(
    274273            array(
     
    280279        );
    281280
    282         // Delete link
     281        // Delete link.
    283282        $delete_link = add_query_arg(
    284283            array(
     
    364363     *
    365364     * @param object $signup_object Signup object instance.
    366      *
    367      * @return int
    368365     */
    369366    public function column_count_sent( $signup_object = null ) {
     
    378375     * @param object|null $signup_object The signup data object.
    379376     * @param string      $column_name   The column name.
    380      *
    381377     * @return string
    382378     */
     
    398394
    399395if ( class_exists( 'WP_MS_Users_List_Table' ) ) :
     396
    400397/**
    401398 * List table class for signups network admin page.
     
    415412
    416413    /**
    417      * Constructor
     414     * Constructor.
    418415     *
    419416     * @since 2.0.0
     
    481478        $views = parent::get_views();
    482479
    483         // Remove the 'current' class from the 'All' link
     480        // Remove the 'current' class from the 'All' link.
    484481        $views['all']        = str_replace( 'class="current"', '', $views['all'] );
    485482        $views['registered'] = sprintf( '<a href="%1$s" class="current">%2$s</a>', esc_url( add_query_arg( 'page', 'bp-signups', bp_get_admin_url( 'users.php' ) ) ), sprintf( _x( 'Pending %s', 'signup users', 'buddypress' ), '<span class="count">(' . number_format_i18n( $this->signup_counts ) . ')</span>' ) );
     
    574571        foreach ( $this->items as $userid => $signup_object ) {
    575572
    576             // Avoid a notice error appearing since 4.3.0
     573            // Avoid a notice error appearing since 4.3.0.
    577574            if ( isset( $signup_object->id ) ) {
    578575                $signup_object->ID = $signup_object->id;
     
    608605     * @param string $column_name   Current column name.
    609606     * @param string $primary       Primary column name.
    610      *
    611607     * @return string
    612608     */
     
    639635        $avatar = get_avatar( $signup_object->user_email, 32 );
    640636
    641         // Activation email link
     637        // Activation email link.
    642638        $email_link = add_query_arg(
    643639            array(
     
    649645        );
    650646
    651         // Activate link
     647        // Activate link.
    652648        $activate_link = add_query_arg(
    653649            array(
     
    659655        );
    660656
    661         // Delete link
     657        // Delete link.
    662658        $delete_link = add_query_arg(
    663659            array(
     
    764760     * @param object|null $signup_object The signup data object.
    765761     * @param string      $column_name   The column name.
    766      *
    767762     * @return string
    768763     */
  • trunk/src/bp-members/bp-members-actions.php

    r10149 r10322  
    11<?php
    22/**
    3  * BuddyPress Members Actions
     3 * BuddyPress Members Actions.
    44 *
    55 * Action functions are exactly the same as screen functions, however they do not
     
    2828
    2929    // Only super admins can currently spam users (but they can't spam
    30     // themselves)
     30    // themselves).
    3131    if ( ! is_super_admin() || bp_is_my_profile() ) {
    3232        return;
    3333    }
    3434
    35     // Use displayed user if it's not yourself
     35    // Use displayed user if it's not yourself.
    3636    if ( empty( $user_id ) )
    3737        $user_id = bp_displayed_user_id();
     
    3939    if ( bp_is_current_component( 'admin' ) && ( in_array( bp_current_action(), array( 'mark-spammer', 'unmark-spammer' ) ) ) ) {
    4040
    41         // Check the nonce
     41        // Check the nonce.
    4242        check_admin_referer( 'mark-unmark-spammer' );
    4343
    44         // To spam or not to spam
     44        // To spam or not to spam.
    4545        $status = bp_is_current_action( 'mark-spammer' ) ? 'spam' : 'ham';
    4646
    47         // The heavy lifting
     47        // The heavy lifting.
    4848        bp_core_process_spammer_status( $user_id, $status );
    4949
    50         // Add feedback message. @todo - Error reporting
     50        // Add feedback message. @todo - Error reporting.
    5151        if ( 'spam' == $status ) {
    5252            bp_core_add_message( __( 'User marked as spammer. Spam users are visible only to site admins.', 'buddypress' ) );
     
    5959        do_action( 'bp_core_action_set_spammer_status', bp_displayed_user_id(), $is_spam );
    6060
    61         // Redirect back to where we came from
     61        // Redirect back to where we came from.
    6262        bp_core_redirect( wp_get_referer() );
    6363    }
    6464}
    65 // Unhooked in 1.6.0 - moved to settings
    66 //add_action( 'bp_actions', 'bp_core_action_set_spammer_status' );
     65
     66/*
     67 * Unhooked in 1.6.0 - moved to settings.
     68 * add_action( 'bp_actions', 'bp_core_action_set_spammer_status' );
     69 */
    6770
    6871/**
     
    7881    if ( bp_is_current_component( 'admin' ) && bp_is_current_action( 'delete-user' ) ) {
    7982
    80         // Check the nonce
     83        // Check the nonce.
    8184        check_admin_referer( 'delete-user' );
    8285
     
    99102    }
    100103}
    101 // Unhooked in 1.6.0 - moved to settings
    102 //add_action( 'bp_actions', 'bp_core_action_delete_user' );
     104
     105/*
     106 * Unhooked in 1.6.0 - moved to settings
     107 * add_action( 'bp_actions', 'bp_core_action_delete_user' );
     108 */
    103109
    104110/**
  • trunk/src/bp-members/bp-members-activity.php

    r10149 r10322  
    4545 * @param string $action   Static activity action.
    4646 * @param object $activity Activity object.
    47  *
    48  * @return string
     47 * @return string $action
    4948 */
    5049function bp_members_format_activity_action_new_member( $action, $activity ) {
     
    5251    $action   = sprintf( __( '%s became a registered member', 'buddypress' ), $userlink );
    5352
    54     // Legacy filter - pass $user_id instead of $activity
     53    // Legacy filter - pass $user_id instead of $activity.
    5554    if ( has_filter( 'bp_core_activity_registered_member_action' ) ) {
    5655        $action = apply_filters( 'bp_core_activity_registered_member_action', $action, $activity->user_id );
     
    7271 *
    7372 * @param array $user Array of userdata passed to bp_core_activated_user hook.
    74  *
    7573 * @return bool
    7674 */
  • trunk/src/bp-members/bp-members-admin.php

    r10314 r10322  
    1515 * Load Members admin area.
    1616 *
    17  * @package BuddyPress
    18  * @subpackage membersAdministration
    19  *
    2017 * @since 2.0.0
    2118 */
     
    103100
    104101        // Paths and URLs
    105         $this->admin_dir = trailingslashit( $bp->plugin_dir  . 'bp-members/admin' ); // Admin path
    106         $this->admin_url = trailingslashit( $bp->plugin_url  . 'bp-members/admin' ); // Admin URL
    107         $this->css_url   = trailingslashit( $this->admin_url . 'css' ); // Admin CSS URL
    108         $this->js_url    = trailingslashit( $this->admin_url . 'js'  ); // Admin CSS URL
    109 
    110         // Capability depends on config
     102        $this->admin_dir = trailingslashit( $bp->plugin_dir  . 'bp-members/admin' ); // Admin path.
     103        $this->admin_url = trailingslashit( $bp->plugin_url  . 'bp-members/admin' ); // Admin URL.
     104        $this->css_url   = trailingslashit( $this->admin_url . 'css' ); // Admin CSS URL.
     105        $this->js_url    = trailingslashit( $this->admin_url . 'js'  ); // Admin CSS URL.
     106
     107        // Capability depends on config.
    111108        $this->capability = bp_core_do_network_admin() ? 'manage_network_users' : 'edit_users';
    112109
    113         // The Edit Profile Screen id
     110        // The Edit Profile Screen id.
    114111        $this->user_page = '';
    115112
    116         // The Show Profile Screen id
     113        // The Show Profile Screen id.
    117114        $this->user_profile = is_network_admin() ? 'users' : 'profile';
    118115
    119         // The current user id
     116        // The current user id.
    120117        $this->current_user_id = get_current_user_id();
    121118
    122         // The user id being edited
     119        // The user id being edited.
    123120        $this->user_id = 0;
    124121
    125         // Is a member editing their own profile
     122        // Is a member editing their own profile.
    126123        $this->is_self_profile = false;
    127124
    128         // The screen ids to load specific css for
     125        // The screen ids to load specific css for.
    129126        $this->screen_id = array();
    130127
    131         // The stats metabox default position
     128        // The stats metabox default position.
    132129        $this->stats_metabox = new StdClass();
    133130
    134         // BuddyPress edit user's profile args
     131        // BuddyPress edit user's profile args.
    135132        $this->edit_profile_args = array( 'page' => 'bp-profile-edit' );
    136133        $this->edit_profile_url  = '';
    137134        $this->edit_url          = '';
    138135
    139         // Data specific to signups
     136        // Data specific to signups.
    140137        $this->users_page   = '';
    141138        $this->signups_page = '';
     
    143140        $this->users_screen = bp_core_do_network_admin() ? 'users-network' : 'users';
    144141
    145         // Specific config: BuddyPress is not network activated
     142        // Specific config: BuddyPress is not network activated.
    146143        $this->subsite_activated = (bool) is_multisite() && ! bp_is_network_activated();
    147144
    148         // When BuddyPress is not network activated, only Super Admin can moderate signups
     145        // When BuddyPress is not network activated, only Super Admin can moderate signups.
    149146        if ( ! empty( $this->subsite_activated ) ) {
    150147            $this->capability = 'manage_network_users';
     
    159156    private function setup_actions() {
    160157
    161         /** Extended Profile **************************************************/
    162 
    163         // Enqueue all admin JS and CSS
     158        /** Extended Profile *************************************************
     159         */
     160
     161        // Enqueue all admin JS and CSS.
    164162        add_action( 'bp_admin_enqueue_scripts', array( $this, 'enqueue_scripts'   )        );
    165163
    166         // Add some page specific output to the <head>
     164        // Add some page specific output to the <head>.
    167165        add_action( 'bp_admin_head',            array( $this, 'admin_head'        ), 999   );
    168166
    169         // Add menu item to all users menu
     167        // Add menu item to all users menu.
    170168        add_action( 'admin_menu',               array( $this, 'admin_menus'       ), 5     );
    171169        add_action( 'network_admin_menu',       array( $this, 'admin_menus'       ), 5     );
    172170        add_action( 'user_admin_menu',          array( $this, 'user_profile_menu' ), 5     );
    173171
    174         // Create the Profile Navigation (Profile/Extended Profile)
     172        // Create the Profile Navigation (Profile/Extended Profile).
    175173        add_action( 'edit_user_profile',        array( $this, 'profile_nav'       ), 99, 1 );
    176174        add_action( 'show_user_profile',        array( $this, 'profile_nav'       ), 99, 1 );
    177175
    178         // Editing users of a specific site
     176        // Editing users of a specific site.
    179177        add_action( "admin_head-site-users.php", array( $this, 'profile_admin_head' ) );
    180178
    181         // Add a row action to users listing
     179        // Add a row action to users listing.
    182180        if ( bp_core_do_network_admin() ) {
    183181            add_filter( 'ms_user_row_actions',        array( $this, 'row_actions'                    ), 10, 2 );
     
    186184        }
    187185
    188         // Add user row actions for single site
     186        // Add user row actions for single site.
    189187        add_filter( 'user_row_actions', array( $this, 'row_actions' ), 10, 2 );
    190188
     
    192190        add_action( 'bp_members_admin_load', array( $this, 'process_member_type_update' ) );
    193191
    194         /** Signups ***********************************************************/
     192        /** Signups **********************************************************
     193         */
    195194
    196195        if ( is_admin() ) {
    197196
    198             // Filter non multisite user query to remove sign-up users
     197            // Filter non multisite user query to remove sign-up users.
    199198            if ( ! is_multisite() ) {
    200199                add_action( 'pre_user_query', array( $this, 'remove_signups_from_user_query' ), 10, 1 );
    201200            }
    202201
    203             // Reorganise the views navigation in users.php and signups page
     202            // Reorganise the views navigation in users.php and signups page.
    204203            if ( current_user_can( $this->capability ) ) {
    205204                add_filter( "views_{$this->users_screen}", array( $this, 'signup_filter_view'    ), 10, 1 );
     
    226225        $this->user_id = (int) get_current_user_id();
    227226
    228         // We'll need a user ID when not on self profile
     227        // We'll need a user ID when not on self profile.
    229228        if ( ! empty( $_GET['user_id'] ) ) {
    230229            $this->user_id = (int) $_GET['user_id'];
     
    237236     * Can the current user edit the one displayed.
    238237     *
    239      * self profile editing / or bp_moderate check.
     238     * Self profile editing / or bp_moderate check.
    240239     * This might be replaced by more granular capabilities
    241240     * in the future.
     
    250249        $retval = false;
    251250
    252         // Bail if no user ID was passed
     251        // Bail if no user ID was passed.
    253252        if ( empty( $user_id ) ) {
    254253            return $retval;
    255254        }
    256255
    257         // Member can edit if they are viewing their own profile
     256        // Member can edit if they are viewing their own profile.
    258257        if ( $this->current_user_id === $user_id ) {
    259258            $retval = true;
    260259
    261         // Trust the 'bp_moderate' capability
     260        // Trust the 'bp_moderate' capability.
    262261        } else {
    263262            $retval = bp_current_user_can( 'bp_moderate' );
     
    276275    private function get_user_notice() {
    277276
    278         // Setup empty notice for return value
     277        // Setup empty notice for return value.
    279278        $notice = array();
    280279
    281         // Updates
     280        // Updates.
    282281        if ( ! empty( $_REQUEST['updated'] ) ) {
    283282            switch ( $_REQUEST['updated'] ) {
     
    309308        }
    310309
    311         // Errors
     310        // Errors.
    312311        if ( ! empty( $_REQUEST['error'] ) ) {
    313312            switch ( $_REQUEST['error'] ) {
     
    363362    public function user_profile_menu() {
    364363
    365         // Setup the hooks array
     364        // Setup the hooks array.
    366365        $hooks = array();
    367366
    368         // Add the faux "Edit Profile" submenu page
     367        // Add the faux "Edit Profile" submenu page.
    369368        $hooks['user'] = $this->user_page = add_submenu_page(
    370369            'profile.php',
     
    376375        );
    377376
    378         // Setup the screen ID's
     377        // Setup the screen ID's.
    379378        $this->screen_id = array(
    380379            $this->user_page    . '-user',
     
    382381        );
    383382
    384         // Loop through new hooks and add method actions
     383        // Loop through new hooks and add method actions.
    385384        foreach ( $hooks as $key => $hook ) {
    386385            add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) );
    387386        }
    388387
    389         // Add the profile_admin_head method to proper admin_head actions
     388        // Add the profile_admin_head method to proper admin_head actions.
    390389        add_action( "admin_head-{$this->user_page}", array( $this, 'profile_admin_head' ) );
    391390        add_action( "admin_head-profile.php",        array( $this, 'profile_admin_head' ) );
     
    401400    public function admin_menus() {
    402401
    403         // Setup the hooks array
     402        // Setup the hooks array.
    404403        $hooks = array();
    405404
    406         // Manage user's profile
     405        // Manage user's profile.
    407406        $hooks['user'] = $this->user_page = add_submenu_page(
    408407            $this->user_profile . '.php',
     
    414413        );
    415414
    416         // Only show sign-ups where they belong
     415        // Only show sign-ups where they belong.
    417416        if ( ! is_multisite() || is_network_admin() ) {
    418417
    419             // Manage signups
     418            // Manage signups.
    420419            $hooks['signups'] = $this->signups_page = add_users_page(
    421420                __( 'Manage Signups',  'buddypress' ),
     
    431430        $this->users_page  = 'users';
    432431
    433         // Self profile check is needed for this pages
     432        // Self profile check is needed for this pages.
    434433        $page_head = array(
    435434            $edit_page        . '.php',
     
    439438        );
    440439
    441         // Append '-network' to each array item if in network admin
     440        // Append '-network' to each array item if in network admin.
    442441        if ( is_network_admin() ) {
    443442            $edit_page          .= '-network';
     
    448447        }
    449448
    450         // Setup the screen ID's
     449        // Setup the screen ID's.
    451450        $this->screen_id = array(
    452451            $edit_page,
     
    455454        );
    456455
    457         // Loop through new hooks and add method actions
     456        // Loop through new hooks and add method actions.
    458457        foreach ( $hooks as $key => $hook ) {
    459458            add_action( "load-{$hook}", array( $this, $key . '_admin_load' ) );
    460459        }
    461460
    462         // Add the profile_admin_head method to proper admin_head actions
     461        // Add the profile_admin_head method to proper admin_head actions.
    463462        foreach ( $page_head as $head ) {
    464463            add_action( "admin_head-{$head}", array( $this, 'profile_admin_head' ) );
     
    478477            $this->is_self_profile = true;
    479478
    480         // Is the user attempting to edit their own profile
     479        // Is the user attempting to edit their own profile.
    481480        } elseif ( isset( $_GET['user_id' ] ) || ( isset( $_GET['page'] ) && ( 'bp-profile-edit' === $_GET['page'] ) ) ) {
    482481            $this->is_self_profile = (bool) ( $this->get_user_id() === $this->current_user_id );
     
    490489        }
    491490
    492         // Editing your own profile, so recheck some vars
     491        // Editing your own profile, so recheck some vars.
    493492        if ( true === $this->is_self_profile ) {
    494493
    495             // Use profile.php as the edit page
     494            // Use profile.php as the edit page.
    496495            $edit_page = 'profile.php';
    497496
    498             // Set profile.php as the parent & sub files to correct the menu nav
     497            // Set profile.php as the parent & sub files to correct the menu nav.
    499498            if ( is_blog_admin() || is_user_admin() ) {
    500499                $parent_file  = 'profile.php';
     
    502501            }
    503502
    504         // Not editing yourself, so use user-edit.php
     503        // Not editing yourself, so use user-edit.php.
    505504        } else {
    506505            $edit_page = 'user-edit.php';
     
    566565        }
    567566
    568         // Only load JavaScript for BuddyPress profile
     567        // Only load JavaScript for BuddyPress profile.
    569568        if ( get_current_screen()->id == $this->user_page ) {
    570569            $js = $this->js_url . "admin{$min}.js";
     
    599598     * @param object|null $user   User to create profile navigation for.
    600599     * @param string      $active Which profile to highlight.
    601      *
    602600     * @return string
    603601     */
    604602    public function profile_nav( $user = null, $active = 'WordPress' ) {
    605603
    606         // Bail if no user ID exists here
     604        // Bail if no user ID exists here.
    607605        if ( empty( $user->ID ) ) {
    608606            return;
    609607        }
    610608
    611         // Add the user ID to query arguments when not editing yourself
     609        // Add the user ID to query arguments when not editing yourself.
    612610        if ( false === $this->is_self_profile ) {
    613611            $query_args = array( 'user_id' => $user->ID );
     
    616614        }
    617615
    618         // Conditionally add a referer if it exists in the existing request
     616        // Conditionally add a referer if it exists in the existing request.
    619617        if ( ! empty( $_REQUEST['wp_http_referer'] ) ) {
    620618            $query_args['wp_http_referer'] = urlencode( stripslashes_deep( $_REQUEST['wp_http_referer'] ) );
    621619        }
    622620
    623         // Setup the two distinct "edit" URL's
     621        // Setup the two distinct "edit" URL's.
    624622        $community_url = add_query_arg( $query_args, $this->edit_profile_url );
    625623        $wordpress_url = add_query_arg( $query_args, $this->edit_url         );
     
    662660    public function user_admin_load() {
    663661
    664         // Get the user ID
     662        // Get the user ID.
    665663        $user_id = $this->get_user_id();
    666664
    667         // can current user edit this profile ?
     665        // Can current user edit this profile?
    668666        if ( ! $this->member_can_edit( $user_id ) ) {
    669667            wp_die( __( 'You cannot edit the requested user.', 'buddypress' ) );
    670668        }
    671669
    672         // Build redirection URL
     670        // Build redirection URL.
    673671        $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham', 'delete_avatar' ), $_SERVER['REQUEST_URI'] );
    674672        $doaction    = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : false;
     
    701699        $allowed_actions = apply_filters( 'bp_members_admin_allowed_actions', array( 'update', 'delete_avatar', 'spam', 'ham' ) );
    702700
    703         // Prepare the display of the Community Profile screen
     701        // Prepare the display of the Community Profile screen.
    704702        if ( ! in_array( $doaction, $allowed_actions ) ) {
    705703            add_screen_option( 'layout_columns', array( 'default' => 2, 'max' => 2, ) );
     
    714712            ) );
    715713
    716             // Help panel - sidebar links
     714            // Help panel - sidebar links.
    717715            get_current_screen()->set_help_sidebar(
    718716                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    731729            );
    732730
    733             // In case xprofile is not active
     731            // In case xprofile is not active.
    734732            $this->stats_metabox->context  = 'normal';
    735733            $this->stats_metabox->priority = 'core';
     
    748746            do_action_ref_array( 'bp_members_admin_xprofile_metabox', array( $user_id, get_current_screen()->id, $this->stats_metabox ) );
    749747
    750             // If xProfile is inactive, difficult to know what's profile we're on
     748            // If xProfile is inactive, difficult to know what's profile we're on.
    751749            if ( 'normal' === $this->stats_metabox->context ) {
    752750                $display_name = bp_core_get_user_displayname( $user_id );
     
    755753            }
    756754
    757             // User Stat metabox
     755            // User Stat metabox.
    758756            add_meta_box(
    759757                'bp_members_admin_user_stats',
     
    793791            do_action( 'bp_members_admin_user_metaboxes', $this->is_self_profile, $user_id );
    794792
    795             // Enqueue JavaScript files
     793            // Enqueue JavaScript files.
    796794            wp_enqueue_script( 'postbox'   );
    797795            wp_enqueue_script( 'dashboard' );
    798796
    799         // Spam or Ham user
     797        // Spam or Ham user.
    800798        } elseif ( in_array( $doaction, array( 'spam', 'ham' ) ) && empty( $this->is_self_profile ) ) {
    801799
     
    810808            bp_core_redirect( $redirect_to );
    811809
    812         // Update other stuff once above ones are done
     810        // Update other stuff once above ones are done.
    813811        } else {
    814812            $this->redirect = $redirect_to;
     
    841839        }
    842840
    843         // Get the user ID
     841        // Get the user ID.
    844842        $user_id = $this->get_user_id();
    845843        $user    = get_user_to_edit( $user_id );
    846844
    847         // Construct title
     845        // Construct title.
    848846        if ( true === $this->is_self_profile ) {
    849847            $title = __( 'Profile',   'buddypress' );
     
    852850        }
    853851
    854         // Construct URL for form
     852        // Construct URL for form.
    855853        $request_url     = remove_query_arg( array( 'action', 'error', 'updated', 'spam', 'ham' ), $_SERVER['REQUEST_URI'] );
    856854        $form_action_url = add_query_arg( 'action', 'update', $request_url );
     
    860858        }
    861859
    862         // Prepare notice for admin
     860        // Prepare notice for admin.
    863861        $notice = $this->get_user_notice();
    864862
     
    947945    public function user_admin_status_metabox( $user = null ) {
    948946
    949         // Bail if no user id or if the user has not activated their account yet
     947        // Bail if no user id or if the user has not activated their account yet.
    950948        if ( empty( $user->ID ) ) {
    951949            return;
    952950        }
    953951
    954         // Bail if user has not been activated yet (how did you get here?)
     952        // Bail if user has not been activated yet (how did you get here?).
    955953        if ( isset( $user->user_status ) && ( 2 == $user->user_status ) ) : ?>
    956954
     
    966964                    <?php
    967965
    968                     // Get the spam status once here to compare against below
     966                    // Get the spam status once here to compare against below.
    969967                    $is_spammer = bp_is_user_spammer( $user->ID );
    970968
     
    989987                        <?php
    990988
    991                         // translators: Publish box date format, see http://php.net/date
     989                        // Translators: Publish box date format, see http://php.net/date.
    992990                        $datef = __( 'M j, Y @ G:i', 'buddypress' );
    993991                        $date  = date_i18n( $datef, strtotime( $user->user_registered ) );
     
    10361034    public function user_admin_stats_metabox( $user = null ) {
    10371035
    1038         // Bail if no user ID
     1036        // Bail if no user ID.
    10391037        if ( empty( $user->ID ) ) {
    10401038            return;
    10411039        }
    10421040
    1043         // If account is not activated last activity is the time user registered
     1041        // If account is not activated last activity is the time user registered.
    10441042        if ( isset( $user->user_status ) && 2 == $user->user_status ) {
    10451043            $last_active = $user->user_registered;
    10461044
    1047         // Account is activated, getting user's last activity
     1045        // Account is activated, getting user's last activity.
    10481046        } else {
    10491047            $last_active = bp_get_user_last_activity( $user->ID );
     
    10571055
    10581056            <?php
    1059             // Loading other stats only if user has activated their account
     1057            // Loading other stats only if user has activated their account.
    10601058            if ( empty( $user->user_status ) ) {
    10611059
     
    11481146     * @param array|string $actions WordPress row actions (edit, delete).
    11491147     * @param object       $user    The object for the user row.
    1150      *
    11511148     * @return array Merged actions.
    11521149     */
    11531150    public function row_actions( $actions = '', $user = null ) {
    11541151
    1155         // Bail if no user ID
     1152        // Bail if no user ID.
    11561153        if ( empty( $user->ID ) ) {
    11571154            return;
    11581155        }
    11591156
    1160         // Setup args array
     1157        // Setup args array.
    11611158        $args = array();
    11621159
    1163         // Add the user ID if it's not for the current user
     1160        // Add the user ID if it's not for the current user.
    11641161        if ( $user->ID !== $this->current_user_id ) {
    11651162            $args['user_id'] = $user->ID;
    11661163        }
    11671164
    1168         // Add the referer
     1165        // Add the referer.
    11691166        $args['wp_http_referer'] = urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) );
    11701167
    1171         // Add the "Extended" link if the current user can edit this user
     1168        // Add the "Extended" link if the current user can edit this user.
    11721169        if ( current_user_can( 'edit_user', $user->ID ) || bp_current_user_can( 'bp_moderate' ) ) {
    11731170
    1174             // Add query args and setup the Extended link
     1171            // Add query args and setup the Extended link.
    11751172            $edit_profile      = add_query_arg( $args, $this->edit_profile_url );
    11761173            $edit_profile_link = sprintf( '<a href="%1$s">%2$s</a>',  esc_url( $edit_profile ), esc_html__( 'Extended', 'buddypress' ) );
     
    11781175            /**
    11791176             * Check the edit action is available
    1180              * and preserve the order edit | profile | remove/delete
     1177             * and preserve the order edit | profile | remove/delete.
    11811178             */
    11821179            if ( ! empty( $actions['edit'] ) ) {
     
    11891186                );
    11901187
    1191             // If not available simply add the edit profile action
     1188            // If not available simply add the edit profile action.
    11921189            } else {
    11931190                $new_edit_actions = array( 'edit-profile' => $edit_profile_link );
     
    12191216     * @param string $url          Profile URL.
    12201217     * @param int    $user_id      User ID.
    1221      *
    12221218     * @return string
    12231219     */
     
    12451241     * @since 2.0.0
    12461242     *
    1247      * @param int    $value
    1248      * @param string $option
    1249      * @param int    $new_value
    1250      *
     1243     * @param int    $value     Value for signup option.
     1244     * @param string $option    Value for the option key.
     1245     * @param int    $new_value Value for the saved option.
    12511246     * @return int The pagination preferences.
    12521247     */
     
    12561251        }
    12571252
    1258         // Per page
     1253        // Per page.
    12591254        $new_value = (int) $new_value;
    12601255        if ( $new_value < 1 || $new_value > 999 ) {
     
    12741269     *
    12751270     * @param WP_User_Query $query The users query.
    1276      *
    12771271     * @return WP_User_Query The users query without the signups.
    12781272     */
     
    12801274        global $wpdb;
    12811275
    1282         // Bail if this is an ajax request
     1276        // Bail if this is an ajax request.
    12831277        if ( defined( 'DOING_AJAX' ) ) {
    12841278            return;
    12851279        }
    12861280
    1287         // Bail if updating BuddyPress
     1281        // Bail if updating BuddyPress.
    12881282        if ( bp_is_update() ) {
    12891283            return;
    12901284        }
    12911285
    1292         // Bail if there is no current admin screen
     1286        // Bail if there is no current admin screen.
    12931287        if ( ! function_exists( 'get_current_screen' ) || ! get_current_screen() ) {
    12941288            return;
    12951289        }
    12961290
    1297         // Get current screen
     1291        // Get current screen.
    12981292        $current_screen = get_current_screen();
    12991293
    1300         // Bail if not on a users page
     1294        // Bail if not on a users page.
    13011295        if ( ! isset( $current_screen->id ) || $this->users_page !== $current_screen->id ) {
    13021296            return;
    13031297        }
    13041298
    1305         // Bail if already querying by an existing role
     1299        // Bail if already querying by an existing role.
    13061300        if ( ! empty( $query->query_vars['role'] ) ) {
    13071301            return;
     
    13171311     *
    13181312     * @param array $views WP List Table views.
    1319      *
    13201313     * @return array The views with the signup view added.
    13211314     */
    13221315    public function signup_filter_view( $views = array() ) {
    13231316
    1324         // Remove the 'current' class from All if we're on the signups view
     1317        // Remove the 'current' class from All if we're on the signups view.
    13251318        if ( $this->signups_page == get_current_screen()->id ) {
    13261319            $views['all'] = str_replace( 'class="current"', '', $views['all'] );
     
    13461339     * @param string $class    The name of the class to use.
    13471340     * @param string $required The parent class.
    1348      *
    1349      * @return WP_List_Table    The List table.
     1341     * @return WP_List_Table The List table.
    13501342     */
    13511343    public static function get_list_table_class( $class = '', $required = '' ) {
     
    13761368        global $bp_members_signup_list_table;
    13771369
    1378         // Build redirection URL
     1370        // Build redirection URL.
    13791371        $redirect_to = remove_query_arg( array( 'action', 'error', 'updated', 'activated', 'notactivated', 'deleted', 'notdeleted', 'resent', 'notresent', 'do_delete', 'do_resend', 'do_activate', '_wpnonce', 'signup_ids' ), $_SERVER['REQUEST_URI'] );
    13801372        $doaction    = bp_admin_list_table_current_bulk_action();
     
    13991391        $allowed_actions = apply_filters( 'bp_signups_admin_allowed_actions', array( 'do_delete', 'do_activate', 'do_resend' ) );
    14001392
    1401         // Prepare the display of the Community Profile screen
     1393        // Prepare the display of the Community Profile screen.
    14021394        if ( ! in_array( $doaction, $allowed_actions ) || ( -1 == $doaction ) ) {
    14031395
     
    14081400            }
    14091401
    1410             // per_page screen option
     1402            // The per_page screen option.
    14111403            add_screen_option( 'per_page', array( 'label' => _x( 'Pending Accounts', 'Pending Accounts per page (screen options)', 'buddypress' ) ) );
    14121404
     
    14321424            ) );
    14331425
    1434             // Help panel - sidebar links
     1426            // Help panel - sidebar links.
    14351427            get_current_screen()->set_help_sidebar(
    14361428                '<p><strong>' . __( 'For more information:', 'buddypress' ) . '</strong></p>' .
     
    14421434            }
    14431435
    1444             // Handle resent activation links
     1436            // Handle resent activation links.
    14451437            if ( 'do_resend' == $doaction ) {
    14461438
    1447                 // nonce check
     1439                // Nonce check.
    14481440                check_admin_referer( 'signups_resend' );
    14491441
     
    14691461                bp_core_redirect( $redirect_to );
    14701462
    1471             // Handle activated accounts
     1463            // Handle activated accounts.
    14721464            } elseif ( 'do_activate' == $doaction ) {
    14731465
    1474                 // nonce check
     1466                // Nonce check.
    14751467                check_admin_referer( 'signups_activate' );
    14761468
     
    14961488                bp_core_redirect( $redirect_to );
    14971489
    1498             // Handle sign-ups delete
     1490            // Handle sign-ups delete.
    14991491            } elseif ( 'do_delete' == $doaction ) {
    15001492
    1501                 // nonce check
     1493                // Nonce check.
    15021494                check_admin_referer( 'signups_delete' );
    15031495
     
    15231515                bp_core_redirect( $redirect_to );
    15241516
    1525             // Plugins can update other stuff from here
     1517            // Plugins can update other stuff from here.
    15261518            } else {
    15271519                $this->redirect = $redirect_to;
     
    15501542    public function signups_display_errors() {
    15511543
    1552         // Look for sign-up errors
     1544        // Look for sign-up errors.
    15531545        $errors = get_transient( '_bp_admin_signups_errors' );
    15541546
    1555         // Bail if no activation errors
     1547        // Bail if no activation errors.
    15561548        if ( empty( $errors ) ) {
    15571549            return;
    15581550        }
    15591551
    1560         // Loop through errors and display them
     1552        // Loop through errors and display them.
    15611553        foreach ( $errors as $error ) : ?>
    15621554
     
    15651557        <?php endforeach;
    15661558
    1567         // Delete the redirect transient
     1559        // Delete the redirect transient.
    15681560        delete_transient( '_bp_admin_signups_errors' );
    15691561    }
     
    15781570    private function get_signup_notice() {
    15791571
    1580         // Setup empty notice for return value
     1572        // Setup empty notice for return value.
    15811573        $notice = array();
    15821574
    1583         // Updates
     1575        // Updates.
    15841576        if ( ! empty( $_REQUEST['updated'] ) ) {
    15851577            switch ( $_REQUEST['updated'] ) {
     
    16881680        }
    16891681
    1690         // Errors
     1682        // Errors.
    16911683        if ( ! empty( $_REQUEST['error'] ) ) {
    16921684            switch ( $_REQUEST['error'] ) {
     
    17331725        $doaction = bp_admin_list_table_current_bulk_action();
    17341726
    1735         // Prepare notices for admin
     1727        // Prepare notices for admin.
    17361728        $notice = $this->get_signup_notice();
    17371729
    1738         // Display notices
     1730        // Display notices.
    17391731        if ( ! empty( $notice ) ) :
    17401732            if ( 'updated' === $notice['class'] ) : ?>
     
    17601752        <?php endif;
    17611753
    1762         // Show the proper screen
     1754        // Show the proper screen.
    17631755        switch ( $doaction ) {
    17641756            case 'activate' :
     
    17881780        $usersearch = ! empty( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
    17891781
    1790         // Prepare the group items for display
     1782        // Prepare the group items for display.
    17911783        $bp_members_signup_list_table->prepare_items();
    17921784
     
    18431835            </h2>
    18441836
    1845             <?php // Display each signups on its own row ?>
     1837            <?php // Display each signups on its own row. ?>
    18461838            <?php $bp_members_signup_list_table->views(); ?>
    18471839
     
    18641856     *
    18651857     * @param string $action Delete, activate, or resend activation link.
    1866      *
    18671858     * @return string
    18681859     */
     
    18721863        }
    18731864
    1874         // Get the user IDs from the URL
     1865        // Get the user IDs from the URL.
    18751866        $ids = false;
    18761867        if ( ! empty( $_POST['allsignups'] ) ) {
     
    18851876
    18861877        // Query for signups, and filter out those IDs that don't
    1887         // correspond to an actual signup
     1878        // correspond to an actual signup.
    18881879        $signups_query = BP_Signup::get( array(
    18891880            'include' => $ids,
     
    18931884        $signup_ids = wp_list_pluck( $signups, 'signup_id' );
    18941885
    1895         // Set up strings
     1886        // Set up strings.
    18961887        switch ( $action ) {
    18971888            case 'delete' :
     
    19231914        }
    19241915
    1925         // These arguments are added to all URLs
     1916        // These arguments are added to all URLs.
    19261917        $url_args = array( 'page' => 'bp-signups' );
    19271918
    1928         // These arguments are only added when performing an action
     1919        // These arguments are only added when performing an action.
    19291920        $action_args = array(
    19301921            'action'     => 'do_' . $action,
     
    19871978    }
    19881979}
    1989 endif; // class_exists check
    1990 
    1991 // Load the BP Members admin
     1980endif; // End class_exists check.
     1981
     1982// Load the BP Members admin.
    19921983add_action( 'bp_init', array( 'BP_Members_Admin', 'register_members_admin' ) );
  • trunk/src/bp-members/bp-members-adminbar.php

    r10190 r10322  
    1717 * @since 1.6.0
    1818 *
    19  * @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support
     19 * @todo Deprecate WP 3.2 Toolbar compatibility when we drop 3.2 support.
    2020 */
    2121function bp_members_admin_bar_my_account_menu() {
    2222    global $wp_admin_bar;
    2323
    24     // Bail if this is an ajax request
     24    // Bail if this is an ajax request.
    2525    if ( defined( 'DOING_AJAX' ) )
    2626        return;
    2727
    28     // Logged in user
     28    // Logged in user.
    2929    if ( is_user_logged_in() ) {
    3030
    3131        $bp = buddypress();
    3232
    33         // Stored in the global so we can add menus easily later on
     33        // Stored in the global so we can add menus easily later on.
    3434        $bp->my_account_menu_id = 'my-account-buddypress';
    3535
    36         // Create the main 'My Account' menu
     36        // Create the main 'My Account' menu.
    3737        $wp_admin_bar->add_menu( array(
    3838            'id'     => $bp->my_account_menu_id,
     
    4444        ) ) );
    4545
    46     // Show login and sign-up links
     46    // Show login and sign-up links.
    4747    } elseif ( !empty( $wp_admin_bar ) ) {
    4848
    4949        add_filter ( 'show_admin_bar', '__return_true' );
    5050
    51         // Create the main 'My Account' menu
     51        // Create the main 'My Account' menu.
    5252        $wp_admin_bar->add_menu( array(
    5353            'id'    => 'bp-login',
     
    5656        ) );
    5757
    58         // Sign up
     58        // Sign up.
    5959        if ( bp_get_signup_allowed() ) {
    6060            $wp_admin_bar->add_menu( array(
     
    7676    global $wp_admin_bar;
    7777
    78     // Only show if viewing a user
     78    // Only show if viewing a user.
    7979    if ( !bp_is_user() )
    8080        return false;
    8181
    82     // Don't show this menu to non site admins or if you're viewing your own profile
     82    // Don't show this menu to non site admins or if you're viewing your own profile.
    8383    if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
    8484        return false;
     
    8686    $bp = buddypress();
    8787
    88     // Unique ID for the 'My Account' menu
     88    // Unique ID for the 'My Account' menu.
    8989    $bp->user_admin_menu_id = 'user-admin';
    9090
    91     // Add the top-level User Admin button
     91    // Add the top-level User Admin button.
    9292    $wp_admin_bar->add_menu( array(
    9393        'id'    => $bp->user_admin_menu_id,
     
    9797
    9898    if ( bp_is_active( 'xprofile' ) ) {
    99         // User Admin > Edit this user's profile
     99        // User Admin > Edit this user's profile.
    100100        $wp_admin_bar->add_menu( array(
    101101            'parent' => $bp->user_admin_menu_id,
     
    105105        ) );
    106106
    107         // User Admin > Edit this user's avatar
     107        // User Admin > Edit this user's avatar.
    108108        if ( buddypress()->avatar->show_avatars ) {
    109109            $wp_admin_bar->add_menu( array(
     
    115115        }
    116116
    117         // User Admin > Edit this user's cover image
     117        // User Admin > Edit this user's cover image.
    118118        if ( bp_displayed_user_use_cover_image_header() ) {
    119119            $wp_admin_bar->add_menu( array(
     
    128128
    129129    if ( bp_is_active( 'settings' ) ) {
    130         // User Admin > Spam/unspam
     130        // User Admin > Spam/unspam.
    131131        $wp_admin_bar->add_menu( array(
    132132            'parent' => $bp->user_admin_menu_id,
     
    136136        ) );
    137137
    138         // User Admin > Delete Account
     138        // User Admin > Delete Account.
    139139        $wp_admin_bar->add_menu( array(
    140140            'parent' => $bp->user_admin_menu_id,
     
    153153 *
    154154 * @since 1.5.0
     155 *
     156 * @return bool
    155157 */
    156158function bp_members_admin_bar_notifications_menu() {
    157159
    158     // Bail if notifications is not active
     160    // Bail if notifications is not active.
    159161    if ( ! bp_is_active( 'notifications' ) ) {
    160162        return false;
  • trunk/src/bp-members/bp-members-filters.php

    r10149 r10322  
    3333function bp_members_signup_sanitization() {
    3434
    35     // Filters on sign-up fields
     35    // Filters on sign-up fields.
    3636    $fields = array (
    3737        'bp_get_signup_username_value',
     
    4444    );
    4545
    46     // Add the filters to each field
     46    // Add the filters to each field.
    4747    foreach( $fields as $filter ) {
    4848        add_filter( $filter, 'esc_html',       1 );
     
    5151    }
    5252
    53     // Sanitize email
     53    // Sanitize email.
    5454    add_filter( 'bp_get_signup_email_value', 'sanitize_email' );
    5555}
     
    6666 * @since 2.1.0
    6767 *
    68  * @param array $illegal_names
    69  *
     68 * @param array $illegal_names Array of illiegal names.
    7069 * @return array $illegal_names
    7170 */
     
    102101 * @param string $url     WP profile edit URL.
    103102 * @param int    $user_id ID of the user.
    104  * @param string $scheme
    105  *
     103 * @param string $scheme  Scheme to use.
    106104 * @return string
    107105 */
    108106function bp_members_edit_profile_url( $url, $user_id, $scheme = 'admin' ) {
    109107
    110     // If xprofile is active, use profile domain link
     108    // If xprofile is active, use profile domain link.
    111109    if ( ! is_admin() && bp_is_active( 'xprofile' ) ) {
    112110        $profile_link = trailingslashit( bp_core_get_user_domain( $user_id ) . bp_get_profile_slug() . '/edit' );
    113111
    114     // Default to $url
     112    // Default to $url.
    115113    } else {
    116114        $profile_link = $url;
  • trunk/src/bp-members/bp-members-functions.php

    r10276 r10322  
    3939    $bp = buddypress();
    4040
    41     // No custom members slug
     41    // No custom members slug.
    4242    if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
    4343        if ( !empty( $bp->pages->members ) ) {
     
    4848    }
    4949
    50     // No custom registration slug
     50    // No custom registration slug.
    5151    if ( !defined( 'BP_REGISTER_SLUG' ) ) {
    5252        if ( !empty( $bp->pages->register ) ) {
     
    5757    }
    5858
    59     // No custom activation slug
     59    // No custom activation slug.
    6060    if ( !defined( 'BP_ACTIVATION_SLUG' ) ) {
    6161        if ( !empty( $bp->pages->activate ) ) {
     
    9898function bp_core_get_users( $args = '' ) {
    9999
    100     // Parse the user query arguments
     100    // Parse the user query arguments.
    101101    $r = bp_parse_args( $args, array(
    102         'type'                => 'active',     // active, newest, alphabetical, random or popular
    103         'user_id'             => false,        // Pass a user_id to limit to only friend connections for this user
    104         'exclude'             => false,        // Users to exclude from results
    105         'search_terms'        => false,        // Limit to users that match these search terms
    106         'meta_key'            => false,        // Limit to users who have this piece of usermeta
    107         'meta_value'          => false,        // With meta_key, limit to users where usermeta matches this value
     102        'type'                => 'active',     // Active, newest, alphabetical, random or popular.
     103        'user_id'             => false,        // Pass a user_id to limit to only friend connections for this user.
     104        'exclude'             => false,        // Users to exclude from results.
     105        'search_terms'        => false,        // Limit to users that match these search terms.
     106        'meta_key'            => false,        // Limit to users who have this piece of usermeta.
     107        'meta_value'          => false,        // With meta_key, limit to users where usermeta matches this value.
    108108        'member_type'         => '',
    109109        'member_type__in'     => '',
    110110        'member_type__not_in' => '',
    111         'include'             => false,        // Pass comma separated list of user_ids to limit to only these users
    112         'per_page'            => 20,           // The number of results to return per page
    113         'page'                => 1,            // The page to return if limiting per page
    114         'populate_extras'     => true,         // Fetch the last active, where the user is a friend, total friend count, latest update
    115         'count_total'         => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false
     111        'include'             => false,        // Pass comma separated list of user_ids to limit to only these users.
     112        'per_page'            => 20,           // The number of results to return per page.
     113        'page'                => 1,            // The page to return if limiting per page.
     114        'populate_extras'     => true,         // Fetch the last active, where the user is a friend, total friend count, latest update.
     115        'count_total'         => 'count_query' // What kind of total user count to do, if any. 'count_query', 'sql_calc_found_rows', or false.
    116116    ), 'core_get_users' );
    117117
     
    131131        );
    132132
    133     // Default behavior as of BuddyPress 1.7
     133    // Default behavior as of BuddyPress 1.7.0.
    134134    } else {
    135135
     
    161161 * @param string|bool $user_nicename Optional. user_nicename of the user.
    162162 * @param string|bool $user_login    Optional. user_login of the user.
    163  *
    164163 * @return string
    165164 */
     
    200199 *
    201200 * @param int $user_id The ID of the user.
    202  *
    203201 * @return array
    204202 */
     
    231229 *
    232230 * @param string $user_login user_login of the user being queried.
    233  *
    234231 * @return int
    235232 */
     
    244241 *
    245242 * @param string $username user_login to check.
    246  *
    247243 * @return int|null The ID of the matched user on success, null on failure.
    248244 */
     
    271267 *
    272268 * @param string $user_nicename user_nicename to check.
    273  *
    274269 * @return int|null The ID of the matched user on success, null on failure.
    275270 */
     
    301296 * @param string|bool $user_nicename Optional. user_nicename of user being checked.
    302297 * @param string|bool $user_login    Optional. user_login of user being checked.
    303  *
    304298 * @return string|bool The username of the matched user, or false.
    305299 */
     
    307301    $bp = buddypress();
    308302
    309     // Check cache for user nicename
     303    // Check cache for user nicename.
    310304    $username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' );
    311305    if ( false === $username ) {
    312306
    313         // Cache not found so prepare to update it
     307        // Cache not found so prepare to update it.
    314308        $update_cache = true;
    315309
    316         // Nicename and login were not passed
     310        // Nicename and login were not passed.
    317311        if ( empty( $user_nicename ) && empty( $user_login ) ) {
    318312
    319             // User ID matches logged in user
     313            // User ID matches logged in user.
    320314            if ( bp_loggedin_user_id() == $user_id ) {
    321315                $userdata = &$bp->loggedin_user->userdata;
    322316
    323             // User ID matches displayed in user
     317            // User ID matches displayed in user.
    324318            } elseif ( bp_displayed_user_id() == $user_id ) {
    325319                $userdata = &$bp->displayed_user->userdata;
    326320
    327             // No user ID match
     321            // No user ID match.
    328322            } else {
    329323                $userdata = false;
    330324            }
    331325
    332             // No match so go dig
     326            // No match so go dig.
    333327            if ( empty( $userdata ) ) {
    334328
    335                 // User not found so return false
     329                // User not found so return false.
    336330                if ( !$userdata = bp_core_get_core_userdata( $user_id ) ) {
    337331                    return false;
     
    339333            }
    340334
    341             // Update the $user_id for later
     335            // Update the $user_id for later.
    342336            $user_id       = $userdata->ID;
    343337
    344             // Two possible options
     338            // Two possible options.
    345339            $user_nicename = $userdata->user_nicename;
    346340            $user_login    = $userdata->user_login;
    347341        }
    348342
    349         // Pull an audible and maybe use the login over the nicename
     343        // Pull an audible and maybe use the login over the nicename.
    350344        $username = bp_is_username_compatibility_mode() ? $user_login : $user_nicename;
    351345
    352     // Username found in cache so don't update it again
     346    // Username found in cache so don't update it again.
    353347    } else {
    354348        $update_cache = false;
    355349    }
    356350
    357     // Add this to cache
     351    // Add this to cache.
    358352    if ( ( true === $update_cache ) && !empty( $username ) ) {
    359353        wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );
    360354
    361355    // @todo bust this cache if no $username found?
    362     //} else {
    363     //  wp_cache_delete( 'bp_user_username_' . $user_id );
     356    // } else {
     357    // wp_cache_delete( 'bp_user_username_' . $user_id );
    364358    }
    365359
     
    385379 *
    386380 * @param int $user_id User ID to check.
    387  *
    388381 * @return string|bool The username of the matched user, or false.
    389382 */
     
    394387        $update_cache = true;
    395388
    396         // User ID matches logged in user
     389        // User ID matches logged in user.
    397390        if ( bp_loggedin_user_id() == $user_id ) {
    398391            $userdata = &$bp->loggedin_user->userdata;
    399392
    400         // User ID matches displayed in user
     393        // User ID matches displayed in user.
    401394        } elseif ( bp_displayed_user_id() == $user_id ) {
    402395            $userdata = &$bp->displayed_user->userdata;
    403396
    404         // No user ID match
     397        // No user ID match.
    405398        } else {
    406399            $userdata = false;
    407400        }
    408401
    409         // No match so go dig
     402        // No match so go dig.
    410403        if ( empty( $userdata ) ) {
    411404
    412             // User not found so return false
     405            // User not found so return false.
    413406            if ( !$userdata = bp_core_get_core_userdata( $user_id ) ) {
    414407                return false;
     
    416409        }
    417410
    418         // User nicename found
     411        // User nicename found.
    419412        $user_nicename = $userdata->user_nicename;
    420413
    421     // Nicename found in cache so don't update it again
     414    // Nicename found in cache so don't update it again.
    422415    } else {
    423416        $update_cache = false;
    424417    }
    425418
    426     // Add this to cache
     419    // Add this to cache.
    427420    if ( true == $update_cache && !empty( $user_nicename ) ) {
    428421        wp_cache_set( 'bp_members_user_nicename_' . $user_id, $user_nicename, 'bp' );
     
    443436 *
    444437 * @param int $uid User ID to check.
    445  *
    446438 * @return string The email for the matched user. Empty string if no user
    447439 *                matched the $uid.
     
    451443    if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) {
    452444
    453         // User exists
     445        // User exists.
    454446        $ud = bp_core_get_core_userdata( $uid );
    455447        if ( ! empty( $ud ) ) {
    456448            $email = $ud->user_email;
    457449
    458         // User was deleted
     450        // User was deleted.
    459451        } else {
    460452            $email = '';
     
    477469 * Return a HTML formatted link for a user with the user's full name as the link text.
    478470 *
    479  * eg: <a href="http://andy.example.com/">Andy Peatling</a>
     471 * Eg: <a href="http://andy.example.com/">Andy Peatling</a>
    480472 *
    481473 * Optional parameters will return just the name or just the URL.
     
    486478 * @param bool $just_link Disable full name and HTML and just return the URL
    487479 *                        text. Default false.
    488  *
    489480 * @return string|bool The link text based on passed parameters, or false on
    490481 *                     no match.
     
    528519 * @since 2.0.0
    529520 *
    530  * @param array $user_ids
    531  *
     521 * @param array $user_ids Array of user IDs to get display names for.
    532522 * @return array
    533523 */
    534524function bp_core_get_user_displaynames( $user_ids ) {
    535525
    536     // Sanitize
     526    // Sanitize.
    537527    $user_ids = wp_parse_id_list( $user_ids );
    538528
    539     // Remove dupes and empties
     529    // Remove dupes and empties.
    540530    $user_ids = array_unique( array_filter( $user_ids ) );
    541531
     
    551541    }
    552542
    553     // Prime caches
     543    // Prime caches.
    554544    if ( ! empty( $uncached_ids ) ) {
    555545        if ( bp_is_active( 'xprofile' ) ) {
    556546            $fullname_data = BP_XProfile_ProfileData::get_value_byid( 1, $uncached_ids );
    557547
    558             // Key by user_id
     548            // Key by user_id.
    559549            $fullnames = array();
    560550            foreach ( $fullname_data as $fd ) {
     
    565555
    566556            // If xprofiledata is not found for any users,  we'll look
    567             // them up separately
     557            // them up separately.
    568558            $no_xprofile_ids = array_diff( $uncached_ids, array_keys( $fullnames ) );
    569559        } else {
     
    573563
    574564        if ( ! empty( $no_xprofile_ids ) ) {
    575             // Use WP_User_Query because we don't need BP information
     565            // Use WP_User_Query because we don't need BP information.
    576566            $query = new WP_User_Query( array(
    577567                'include'     => $no_xprofile_ids,
     
    585575
    586576                // If xprofile is active, set this value as the
    587                 // xprofile display name as well
     577                // xprofile display name as well.
    588578                if ( bp_is_active( 'xprofile' ) ) {
    589579                    xprofile_set_field_data( 1, $qr->ID, $fullnames[ $qr->ID ] );
     
    609599 *
    610600 * @param int|string|bool $user_id_or_username User ID or username.
    611  *
    612601 * @return string|bool The display name for the user in question, or false if
    613602 *                     user not found.
     
    655644 *
    656645 * @param string $email The email address for the user.
    657  *
    658646 * @return string The link to the users home base. False on no match.
    659647 */
     
    677665 *                         this should be user_login, otherwise it should
    678666 *                         be user_nicename.
    679  *
    680667 * @return string|bool The link to the user's domain, false on no match.
    681668 */
     
    739726        $bp = buddypress();
    740727
    741         // Avoid a costly join by splitting the lookup
     728        // Avoid a costly join by splitting the lookup.
    742729        if ( is_multisite() ) {
    743730            $sql = "SELECT ID FROM {$wpdb->users} WHERE (user_status != 0 OR deleted != 0 OR user_status != 0)";
     
    781768 *                              performed this cleanup independently, as when hooked
    782769 *                              to 'make_spam_user'.
    783  *
    784770 * @return bool True on success, false on failure.
    785771 */
     
    787773    global $wpdb;
    788774
    789     // Bail if no user ID
     775    // Bail if no user ID.
    790776    if ( empty( $user_id ) ) {
    791777        return;
    792778    }
    793779
    794     // Bail if user ID is super admin
     780    // Bail if user ID is super admin.
    795781    if ( is_super_admin( $user_id ) ) {
    796782        return;
    797783    }
    798784
    799     // Get the functions file
     785    // Get the functions file.
    800786    if ( is_multisite() ) {
    801787        require_once( ABSPATH . 'wp-admin/includes/ms.php' );
     
    804790    $is_spam = ( 'spam' == $status );
    805791
    806     // Only you can prevent infinite loops
     792    // Only you can prevent infinite loops.
    807793    remove_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' );
    808794    remove_action( 'make_ham_user',  'bp_core_mark_user_ham_admin'  );
    809795
    810     // force the cleanup of WordPress content and status for multisite configs
     796    // Force the cleanup of WordPress content and status for multisite configs.
    811797    if ( $do_wp_cleanup ) {
    812798
    813         // Get the blogs for the user
     799        // Get the blogs for the user.
    814800        $blogs = get_blogs_of_user( $user_id, true );
    815801
    816802        foreach ( (array) array_values( $blogs ) as $details ) {
    817803
    818             // Do not mark the main or current root blog as spam
     804            // Do not mark the main or current root blog as spam.
    819805            if ( 1 == $details->userblog_id || bp_get_root_blog_id() == $details->userblog_id ) {
    820806                continue;
    821807            }
    822808
    823             // Update the blog status
     809            // Update the blog status.
    824810            update_blog_status( $details->userblog_id, 'spam', $is_spam );
    825811        }
    826812
    827         // Finally, mark this user as a spammer
     813        // Finally, mark this user as a spammer.
    828814        if ( is_multisite() ) {
    829815            update_user_status( $user_id, 'spam', $is_spam );
     
    831817    }
    832818
    833     // Update the user status
     819    // Update the user status.
    834820    $wpdb->update( $wpdb->users, array( 'user_status' => $is_spam ), array( 'ID' => $user_id ) );
    835821
    836     // Clean user cache
     822    // Clean user cache.
    837823    clean_user_cache( $user_id );
    838824
    839825    if ( ! is_multisite() ) {
    840         // Call multisite actions in single site mode for good measure
     826        // Call multisite actions in single site mode for good measure.
    841827        if ( true === $is_spam ) {
    842828
     
    862848    }
    863849
    864     // Hide this user's activity
     850    // Hide this user's activity.
    865851    if ( ( true === $is_spam ) && bp_is_active( 'activity' ) ) {
    866852        bp_activity_hide_user_activity( $user_id );
    867853    }
    868854
    869     // We need a special hook for is_spam so that components can delete data at spam time
     855    // We need a special hook for is_spam so that components can delete data at spam time.
    870856    if ( true === $is_spam ) {
    871857
     
    900886    do_action( 'bp_core_process_spammer_status', $user_id, $is_spam );
    901887
    902     // Put things back how we found them
     888    // Put things back how we found them.
    903889    add_action( 'make_spam_user', 'bp_core_mark_user_spam_admin' );
    904890    add_action( 'make_ham_user',  'bp_core_mark_user_ham_admin'  );
     
    934920 *
    935921 * @param int $user_id The ID for the user.
    936  *
    937922 * @return bool True if spammer, otherwise false.
    938923 */
    939924function bp_is_user_spammer( $user_id = 0 ) {
    940925
    941     // No user to check
     926    // No user to check.
    942927    if ( empty( $user_id ) ) {
    943928        return false;
     
    946931    $bp = buddypress();
    947932
    948     // Assume user is not spam
     933    // Assume user is not spam.
    949934    $is_spammer = false;
    950935
    951     // Setup our user
     936    // Setup our user.
    952937    $user = false;
    953938
    954     // Get locally-cached data if available
     939    // Get locally-cached data if available.
    955940    switch ( $user_id ) {
    956941        case bp_loggedin_user_id() :
     
    963948    }
    964949
    965     // Manually get userdata if still empty
     950    // Manually get userdata if still empty.
    966951    if ( empty( $user ) ) {
    967952        $user = get_userdata( $user_id );
    968953    }
    969954
    970     // No user found
     955    // No user found.
    971956    if ( empty( $user ) ) {
    972957        $is_spammer = false;
    973958
    974     // User found
     959    // User found.
    975960    } else {
    976961
    977         // Check if spam
     962        // Check if spam.
    978963        if ( !empty( $user->spam ) ) {
    979964            $is_spammer = true;
     
    999984 *
    1000985 * @param int $user_id The ID for the user.
    1001  *
    1002986 * @return bool True if deleted, otherwise false.
    1003987 */
    1004988function bp_is_user_deleted( $user_id = 0 ) {
    1005989
    1006     // No user to check
     990    // No user to check.
    1007991    if ( empty( $user_id ) ) {
    1008992        return false;
     
    1011995    $bp = buddypress();
    1012996
    1013     // Assume user is not deleted
     997    // Assume user is not deleted.
    1014998    $is_deleted = false;
    1015999
    1016     // Setup our user
     1000    // Setup our user.
    10171001    $user = false;
    10181002
    1019     // Get locally-cached data if available
     1003    // Get locally-cached data if available.
    10201004    switch ( $user_id ) {
    10211005        case bp_loggedin_user_id() :
     
    10281012    }
    10291013
    1030     // Manually get userdata if still empty
     1014    // Manually get userdata if still empty.
    10311015    if ( empty( $user ) ) {
    10321016        $user = get_userdata( $user_id );
    10331017    }
    10341018
    1035     // No user found
     1019    // No user found.
    10361020    if ( empty( $user ) ) {
    10371021        $is_deleted = true;
    10381022
    1039     // User found
     1023    // User found.
    10401024    } else {
    10411025
    1042         // Check if deleted
     1026        // Check if deleted.
    10431027        if ( !empty( $user->deleted ) ) {
    10441028            $is_deleted = true;
     
    10711055 *
    10721056 * @param int $user_id The user ID to check.
    1073  *
    10741057 * @return bool True if active, otherwise false.
    10751058 */
    10761059function bp_is_user_active( $user_id = 0 ) {
    10771060
    1078     // Default to current user
     1061    // Default to current user.
    10791062    if ( empty( $user_id ) && is_user_logged_in() ) {
    10801063        $user_id = bp_loggedin_user_id();
    10811064    }
    10821065
    1083     // No user to check
     1066    // No user to check.
    10841067    if ( empty( $user_id ) ) {
    10851068        return false;
    10861069    }
    10871070
    1088     // Check spam
     1071    // Check spam.
    10891072    if ( bp_is_user_spammer( $user_id ) ) {
    10901073        return false;
    10911074    }
    10921075
    1093     // Check deleted
     1076    // Check deleted.
    10941077    if ( bp_is_user_deleted( $user_id ) ) {
    10951078        return false;
    10961079    }
    10971080
    1098     // Assume true if not spam or deleted
     1081    // Assume true if not spam or deleted.
    10991082    return true;
    11001083}
     
    11131096 *
    11141097 * @param int $user_id The user ID to check.
    1115  *
    11161098 * @return bool True if inactive, otherwise false.
    11171099 */
    11181100function bp_is_user_inactive( $user_id = 0 ) {
    11191101
    1120     // Default to current user
     1102    // Default to current user.
    11211103    if ( empty( $user_id ) && is_user_logged_in() ) {
    11221104        $user_id = bp_loggedin_user_id();
    11231105    }
    11241106
    1125     // No user to check
     1107    // No user to check.
    11261108    if ( empty( $user_id ) ) {
    11271109        return false;
    11281110    }
    11291111
    1130     // Return the inverse of active
     1112    // Return the inverse of active.
    11311113    return !bp_is_user_active( $user_id );
    11321114}
     
    11391121 * @param int    $user_id ID of the user being updated.
    11401122 * @param string $time    Time of last activity, in 'Y-m-d H:i:s' format.
    1141  *
    11421123 * @return bool True on success, false on failure.
    11431124 */
    11441125function bp_update_user_last_activity( $user_id = 0, $time = '' ) {
    11451126
    1146     // Fall back on current user
     1127    // Fall back on current user.
    11471128    if ( empty( $user_id ) ) {
    11481129        $user_id = bp_loggedin_user_id();
    11491130    }
    11501131
    1151     // Bail if the user id is 0, as there's nothing to update
     1132    // Bail if the user id is 0, as there's nothing to update.
    11521133    if ( empty( $user_id ) ) {
    11531134        return false;
    11541135    }
    11551136
    1156     // Fall back on current time
     1137    // Fall back on current time.
    11571138    if ( empty( $time ) ) {
    11581139        $time = bp_core_current_time();
     
    11831164 * @access private For internal use only.
    11841165 *
    1185  * @param null   $retval
     1166 * @param null   $retval Null retval value.
    11861167 * @param int    $object_id ID of the user.
    11871168 * @param string $meta_key  Meta key being fetched.
    1188  *
    11891169 * @return mixed
    11901170 */
     
    11931173
    11941174    if ( 'last_activity' === $meta_key ) {
    1195         // Don't send the warning more than once per pageload
     1175        // Don't send the warning more than once per pageload.
    11961176        if ( false === $warned ) {
    11971177            _doing_it_wrong( 'get_user_meta( $user_id, \'last_activity\' )', __( 'User last_activity data is no longer stored in usermeta. Use bp_get_user_last_activity() instead.', 'buddypress' ), '2.0.0' );
     
    12351215 *
    12361216 * @param int $user_id The ID of the user.
    1237  *
    12381217 * @return string Time of last activity, in 'Y-m-d H:i:s' format, or an empty
    12391218 *                string if none is found.
     
    12741253    // Wipe out existing last_activity data in the activity table -
    12751254    // this helps to prevent duplicates when pulling from the usermeta
    1276     // table
     1255    // table.
    12771256    $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->members->table_name_last_activity} WHERE component = %s AND type = 'last_activity'", $bp->members->id ) );
    12781257
     
    12951274 *
    12961275 * @param int $user_id ID of the user being queried.
    1297  *
    12981276 * @return array Post IDs.
    12991277 */
     
    13191297function bp_core_delete_account( $user_id = 0 ) {
    13201298
    1321     // Use logged in user ID if none is passed
     1299    // Use logged in user ID if none is passed.
    13221300    if ( empty( $user_id ) ) {
    13231301        $user_id = bp_loggedin_user_id();
    13241302    }
    13251303
    1326     // Site admins cannot be deleted
     1304    // Site admins cannot be deleted.
    13271305    if ( is_super_admin( $user_id ) ) {
    13281306        return false;
    13291307    }
    13301308
    1331     // Extra checks if user is not deleting themselves
     1309    // Extra checks if user is not deleting themselves.
    13321310    if ( bp_loggedin_user_id() !== absint( $user_id ) ) {
    13331311
    1334         // Bail if current user cannot delete any users
     1312        // Bail if current user cannot delete any users.
    13351313        if ( ! bp_current_user_can( 'delete_users' ) ) {
    13361314            return false;
    13371315        }
    13381316
    1339         // Bail if current user cannot delete this user
     1317        // Bail if current user cannot delete this user.
    13401318        if ( ! current_user_can_for_blog( bp_get_root_blog_id(), 'delete_user', $user_id ) ) {
    13411319            return false;
     
    13521330    do_action( 'bp_core_pre_delete_account', $user_id );
    13531331
    1354     // Specifically handle multi-site environment
     1332    // Specifically handle multi-site environment.
    13551333    if ( is_multisite() ) {
    13561334        require_once( ABSPATH . '/wp-admin/includes/ms.php'   );
     
    13591337        $retval = wpmu_delete_user( $user_id );
    13601338
    1361     // Single site user deletion
     1339    // Single site user deletion.
    13621340    } else {
    13631341        require_once( ABSPATH . '/wp-admin/includes/user.php' );
     
    13831361 *
    13841362 * @param int $user_id ID of the user who is about to be deleted.
    1385  *
    13861363 * @return bool True on success, false on failure.
    13871364 */
     
    14011378 *
    14021379 * @param string $str String to be upper-cased.
    1403  *
    14041380 * @return string
    14051381 */
     
    14231399 * @param WP_User|WP_Error $user Either the WP_User object or the WP_Error
    14241400 *                               object, as passed to the 'authenticate' filter.
    1425  *
    14261401 * @return WP_User|WP_Error If the user is not a spammer, return the WP_User
    14271402 *                          object. Otherwise a new WP_Error object.
     
    14291404function bp_core_boot_spammer( $user ) {
    14301405
    1431     // check to see if the $user has already failed logging in, if so return $user as-is
     1406    // Check to see if the $user has already failed logging in, if so return $user as-is.
    14321407    if ( is_wp_error( $user ) || empty( $user ) ) {
    14331408        return $user;
    14341409    }
    14351410
    1436     // the user exists; now do a check to see if the user is a spammer
     1411    // The user exists; now do a check to see if the user is a spammer
    14371412    // if the user is a spammer, stop them in their tracks!
    14381413    if ( is_a( $user, 'WP_User' ) && ( ( is_multisite() && (int) $user->spam ) || 1 == $user->user_status ) ) {
     
    14401415    }
    14411416
    1442     // user is good to go!
     1417    // User is good to go!
    14431418    return $user;
    14441419}
     
    14521427function bp_core_remove_data( $user_id ) {
    14531428
    1454     // Remove last_activity data
     1429    // Remove last_activity data.
    14551430    BP_Core_User::delete_last_activity( $user_id );
    14561431
    1457     // Flush the cache to remove the user from all cached objects
     1432    // Flush the cache to remove the user from all cached objects.
    14581433    wp_cache_flush();
    14591434}
     
    14991474 *                               Multisite settings.
    15001475 * @param array|string $oldvalue The old value of the option.
    1501  *
    15021476 * @return array Merged and unique array of illegal names.
    15031477 */
    15041478function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) {
    15051479
    1506     // Make sure $value is array
     1480    // Make sure $value is array.
    15071481    if ( empty( $value ) ) {
    15081482        $db_illegal_names = array();
     
    15311505    );
    15321506
    1533     // Core constants
     1507    // Core constants.
    15341508    $slug_constants = array(
    15351509        'BP_GROUPS_SLUG',
     
    15611535    $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) );
    15621536
    1563     // Merge the arrays together
     1537    // Merge the arrays together.
    15641538    $merged_names           = array_merge( (array) $filtered_illegal_names, (array) $db_illegal_names );
    15651539
    1566     // Remove duplicates
     1540    // Remove duplicates.
    15671541    $illegal_names          = array_unique( (array) $merged_names );
    15681542
     
    15901564 *
    15911565 * @param string $user_email The email being checked.
    1592  *
    15931566 * @return bool|array True if the address passes all checks; otherwise an array
    15941567 *                    of error codes.
     
    16051578
    16061579    // Is the email on the Banned Email Domains list?
    1607     // Note: This check only works on Multisite
     1580    // Note: This check only works on Multisite.
    16081581    if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) ) {
    16091582        $errors['domain_banned'] = 1;
     
    16111584
    16121585    // Is the email on the Limited Email Domains list?
    1613     // Note: This check only works on Multisite
     1586    // Note: This check only works on Multisite.
    16141587    $limited_email_domains = get_site_option( 'limited_email_domains' );
    16151588    if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
     
    16681641 * @param string $user_name  Username to validate.
    16691642 * @param string $user_email Email address to validate.
    1670  *
    16711643 * @return array Results of user validation including errors, if any.
    16721644 */
    16731645function bp_core_validate_user_signup( $user_name, $user_email ) {
    16741646
    1675     // Make sure illegal names include BuddyPress slugs and values
     1647    // Make sure illegal names include BuddyPress slugs and values.
    16761648    bp_core_flush_illegal_names();
    16771649
     
    16831655    // When not running Multisite, we perform our own validation. What
    16841656    // follows reproduces much of the logic of wpmu_validate_user_signup(),
    1685     // minus the multisite-specific restrictions on user_login
     1657    // minus the multisite-specific restrictions on user_login.
    16861658    } else {
    16871659        $errors = new WP_Error();
     
    16961668        $user_name = apply_filters( 'pre_user_login', $user_name );
    16971669
    1698         // User name can't be empty
     1670        // User name can't be empty.
    16991671        if ( empty( $user_name ) ) {
    17001672            $errors->add( 'user_name', __( 'Please enter a username', 'buddypress' ) );
    17011673        }
    17021674
    1703         // user name can't be on the blacklist
     1675        // User name can't be on the blacklist.
    17041676        $illegal_names = get_site_option( 'illegal_names' );
    17051677        if ( in_array( $user_name, (array) $illegal_names ) ) {
     
    17071679        }
    17081680
    1709         // User name must pass WP's validity check
     1681        // User name must pass WP's validity check.
    17101682        if ( ! validate_username( $user_name ) ) {
    17111683            $errors->add( 'user_name', __( 'Usernames can contain only letters, numbers, ., -, and @', 'buddypress' ) );
    17121684        }
    17131685
    1714         // Minimum of 4 characters
     1686        // Minimum of 4 characters.
    17151687        if ( strlen( $user_name ) < 4 ) {
    17161688            $errors->add( 'user_name',  __( 'Username must be at least 4 characters', 'buddypress' ) );
     
    17291701        }
    17301702
    1731         // Check into signups
     1703        // Check into signups.
    17321704        $signups = BP_Signup::get( array(
    17331705            'user_login' => $user_name,
     
    17421714
    17431715        // Validate the email address and process the validation results into
    1744         // error messages
     1716        // error messages.
    17451717        $validate_email = bp_core_validate_email_address( $user_email );
    17461718        bp_core_add_validation_error_messages( $errors, $validate_email );
    17471719
    1748         // Assemble the return array
     1720        // Assemble the return array.
    17491721        $result = array(
    17501722            'user_name'  => $user_name,
     
    17531725        );
    17541726
    1755         // Apply WPMU legacy filter
     1727        // Apply WPMU legacy filter.
    17561728        $result = apply_filters( 'wpmu_validate_user_signup', $result );
    17571729    }
     
    17741746 * @param string $blog_url   Blog URL requested during registration.
    17751747 * @param string $blog_title Blog title requested during registration.
    1776  *
    17771748 * @return array
    17781749 */
     
    18021773 * @param array  $usermeta      Miscellaneous metadata about the user (blog-specific
    18031774 *                              signup data, xprofile data, etc).
    1804  *
    18051775 * @return bool|WP_Error True on success, WP_Error on failure.
    18061776 */
     
    18081778    $bp = buddypress();
    18091779
    1810     // We need to cast $user_id to pass to the filters
     1780    // We need to cast $user_id to pass to the filters.
    18111781    $user_id = false;
    18121782
    1813     // Multisite installs have their own install procedure
     1783    // Multisite installs have their own install procedure.
    18141784    if ( is_multisite() ) {
    18151785        wpmu_signup_user( $user_login, $user_email, $usermeta );
    18161786
    18171787    } else {
    1818         // Format data
     1788        // Format data.
    18191789        $user_login     = preg_replace( '/\s+/', '', sanitize_user( $user_login, true ) );
    18201790        $user_email     = sanitize_email( $user_email );
     
    18991869 * @param string $user_email  Email address of requesting user.
    19001870 * @param string $usermeta    Miscellaneous metadata for the user.
    1901  *
    19021871 * @return bool
    19031872 */
     
    19081877
    19091878    /**
    1910      * Filters the result of wpmu_signup_blog()
     1879     * Filters the result of wpmu_signup_blog().
    19111880     *
    19121881     * This filter provides no value and is retained for
     
    19241893 *
    19251894 * @param string $key Activation key.
    1926  *
    19271895 * @return int|bool User ID on success, false on failure.
    19281896 */
     
    19321900    $user = false;
    19331901
    1934     // Multisite installs have their own activation routine
     1902    // Multisite installs have their own activation routine.
    19351903    if ( is_multisite() ) {
    19361904        $user = wpmu_activate_signup( $key );
    19371905
    1938         // If there were errors, add a message and redirect
     1906        // If there were errors, add a message and redirect.
    19391907        if ( ! empty( $user->errors ) ) {
    19401908            return $user;
     
    19621930        }
    19631931
    1964         // password is hashed again in wp_insert_user
     1932        // Password is hashed again in wp_insert_user.
    19651933        $password = wp_generate_password( 12, false );
    19661934
    19671935        $user_id = username_exists( $signup->user_login );
    19681936
    1969         // Create the user
     1937        // Create the user.
    19701938        if ( ! $user_id ) {
    19711939            $user_id = wp_create_user( $signup->user_login, $password, $signup->user_email );
     
    19741942        // created locally for backward compatibility. Process it.
    19751943        } elseif ( $key == wp_hash( $user_id ) ) {
    1976             // Change the user's status so they become active
     1944            // Change the user's status so they become active.
    19771945            if ( ! $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 0 WHERE ID = %d", $user_id ) ) ) {
    19781946                return new WP_Error( 'invalid_key', __( 'Invalid activation key.', 'buddypress' ) );
     
    19941962        }
    19951963
    1996         // Fetch the signup so we have the data later on
     1964        // Fetch the signup so we have the data later on.
    19971965        $signups = BP_Signup::get( array(
    19981966            'activation_key' => $key,
     
    20011969        $signup = isset( $signups['signups'] ) && ! empty( $signups['signups'][0] ) ? $signups['signups'][0] : false;
    20021970
    2003         // Activate the signup
     1971        // Activate the signup.
    20041972        BP_Signup::validate( $key );
    20051973
     
    20081976        }
    20091977
    2010         // Set up data to pass to the legacy filter
     1978        // Set up data to pass to the legacy filter.
    20111979        $user = array(
    20121980            'user_id'  => $user_id,
     
    20151983        );
    20161984
    2017         // Notify the site admin of a new user registration
     1985        // Notify the site admin of a new user registration.
    20181986        wp_new_user_notification( $user_id );
    20191987
     
    20342002    }
    20352003
    2036     // Set any profile data
     2004    // Set any profile data.
    20372005    if ( bp_is_active( 'xprofile' ) ) {
    20382006        if ( ! empty( $user['meta']['profile_field_ids'] ) ) {
     
    20462014                }
    20472015
    2048                 // Save the visibility level
     2016                // Save the visibility level.
    20492017                $visibility_level = ! empty( $user['meta']['field_' . $field_id . '_visibility'] ) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public';
    20502018                xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );
     
    20532021    }
    20542022
    2055     // Update the display_name
     2023    // Update the display_name.
    20562024    wp_update_user( array(
    20572025        'ID'           => $user_id,
     
    20592027    ) );
    20602028
    2061     // Set the password on multisite installs
     2029    // Set the password on multisite installs.
    20622030    if ( ! empty( $user['meta']['password'] ) ) {
    20632031        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id ) );
     
    21022070
    21032071        // Fetch activation keys separately, to avoid the all_with_meta
    2104         // overhead
     2072        // overhead.
    21052073        $status_2_ids_sql = implode( ',', $status_2_ids );
    21062074        $ak_data = $wpdb->get_results( "SELECT user_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'activation_key' AND user_id IN ({$status_2_ids_sql})" );
    21072075
    2108         // Rekey
     2076        // Rekey.
    21092077        $activation_keys = array();
    21102078        foreach ( $ak_data as $ak_datum ) {
     
    21142082        unset( $status_2_ids_sql, $status_2_ids, $ak_data );
    21152083
    2116         // Merge
     2084        // Merge.
    21172085        foreach ( $signups as &$signup ) {
    21182086            if ( isset( $activation_keys[ $signup->ID ] ) ) {
     
    21212089        }
    21222090
    2123         // Reset the signup var as we're using it to process the migration
     2091        // Reset the signup var as we're using it to process the migration.
    21242092        unset( $signup );
    21252093
     
    21312099        $meta = array();
    21322100
    2133         // Rebuild the activation key, if missing
     2101        // Rebuild the activation key, if missing.
    21342102        if ( empty( $signup->activation_key ) ) {
    21352103            $signup->activation_key = wp_hash( $signup->ID );
     
    21532121        ) );
    21542122
    2155         // Deleting these options will remove signups from users count
     2123        // Deleting these options will remove signups from users count.
    21562124        delete_user_option( $signup->ID, 'capabilities' );
    21572125        delete_user_option( $signup->ID, 'user_level'   );
     
    21662134 *
    21672135 * @param int $user_id ID of the user.
    2168  *
    21692136 * @return bool
    21702137 */
     
    21762143    }
    21772144
    2178     // Add the user's fullname to Xprofile
     2145    // Add the user's fullname to Xprofile.
    21792146    if ( bp_is_active( 'xprofile' ) ) {
    21802147        $firstname = bp_get_user_meta( $user_id, 'first_name', true );
     
    22962263 * @param string           $username The inputted, attempted username.
    22972264 * @param string           $password The inputted, attempted password.
    2298  *
    22992265 * @return WP_User|WP_Error
    23002266 */
    23012267function bp_core_signup_disable_inactive( $user = null, $username = '', $password ='' ) {
    2302     // login form not used
     2268    // Login form not used.
    23032269    if ( empty( $username ) && empty( $password ) ) {
    23042270        return $user;
     
    23122278
    23132279    // If no WP_User is found corresponding to the username, this
    2314     // is a potential signup
     2280    // is a potential signup.
    23152281    } elseif ( is_wp_error( $user ) && 'invalid_username' == $user->get_error_code() ) {
    23162282        $user_login = $username;
    23172283
    2318     // This is an activated user, so bail
     2284    // This is an activated user, so bail.
    23192285    } else {
    23202286        return $user;
    23212287    }
    23222288
    2323     // Look for the unactivated signup corresponding to the login name
     2289    // Look for the unactivated signup corresponding to the login name.
    23242290    $signup = BP_Signup::get( array( 'user_login' => sanitize_user( $user_login ) ) );
    23252291
     
    23302296
    23312297    // Unactivated user account found!
    2332     // Set up the feedback message
     2298    // Set up the feedback message.
    23332299    $signup_id = $signup['signups'][0]->signup_id;
    23342300
     
    23632329    }
    23642330
    2365     // verify nonce
     2331    // Verify nonce.
    23662332    if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'bp-resend-activation' ) ) {
    23672333        die( 'Security check' );
     
    23702336    $signup_id = (int) $_GET['id'];
    23712337
    2372     // resend the activation email
    2373     // also updates the 'last sent' and '# of emails sent' values
     2338    // Resend the activation email.
     2339    // also updates the 'last sent' and '# of emails sent' values.
    23742340    $resend = BP_Signup::resend( array( $signup_id ) );
    23752341
    2376     // add feedback message
     2342    // Add feedback message.
    23772343    if ( ! empty( $resend['errors'] ) ) {
    23782344        $error = __( '<strong>ERROR</strong>: Your account has already been activated.', 'buddypress' );
     
    23882354function bp_core_wpsignup_redirect() {
    23892355
    2390     // Bail in admin or if custom signup page is broken
     2356    // Bail in admin or if custom signup page is broken.
    23912357    if ( is_admin() || ! bp_has_custom_signup_page() ) {
    23922358        return;
     
    23952361    $action = !empty( $_GET['action'] ) ? $_GET['action'] : '';
    23962362
    2397     // Not at the WP core signup page and action is not register
     2363    // Not at the WP core signup page and action is not register.
    23982364    if ( ! empty( $_SERVER['SCRIPT_NAME'] ) && false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) && ( 'register' != $action ) ) {
    23992365        return;
     
    24262392 */
    24272393function bp_stop_live_spammer() {
    2428     // if we're on the login page, stop now to prevent redirect loop
     2394    // If we're on the login page, stop now to prevent redirect loop.
    24292395    $is_login = false;
    24302396    if ( isset( $GLOBALS['pagenow'] ) && ( false !== strpos( $GLOBALS['pagenow'], 'wp-login.php' ) ) ) {
     
    24382404    }
    24392405
    2440     // user isn't logged in, so stop!
     2406    // User isn't logged in, so stop!
    24412407    if ( ! is_user_logged_in() ) {
    24422408        return;
    24432409    }
    24442410
    2445     // if spammer, redirect to wp-login.php and reauthorize
     2411    // If spammer, redirect to wp-login.php and reauthorize.
    24462412    if ( bp_is_user_spammer( bp_loggedin_user_id() ) ) {
    2447         // setup login args
     2413        // Setup login args.
    24482414        $args = array(
    2449             // custom action used to throw an error message
     2415            // Custom action used to throw an error message.
    24502416            'action' => 'bp-spam',
    24512417
    2452             // reauthorize user to login
     2418            // Reauthorize user to login.
    24532419            'reauth' => 1
    24542420        );
     
    24632429        $login_url = apply_filters( 'bp_live_spammer_redirect', add_query_arg( $args, wp_login_url() ) );
    24642430
    2465         // redirect user to login page
     2431        // Redirect user to login page.
    24662432        wp_redirect( $login_url );
    24672433        die();
     
    24802446    $error = __( '<strong>ERROR</strong>: Your account has been marked as a spammer.', 'buddypress' );
    24812447
    2482     // shake shake shake!
     2448    // Shake shake shake!
    24832449    add_action( 'login_head', 'wp_shake_js', 12 );
    24842450}
     
    25872553 *
    25882554 * @param string $member_type The name of the member type.
    2589  *
    25902555 * @return object A member type object.
    25912556 */
     
    26142579 *                               element from the array needs to match; 'and' means all elements
    26152580 *                               must match. Accepts 'or' or 'and'. Default 'and'.
    2616  *
    26172581 * @return array A list of member type names or objects.
    26182582 */
     
    26522616 * @param bool   $append      Optional. True to append this to existing types for user,
    26532617 *                            false to replace. Default: false.
    2654  * @return See {@see bp_set_object_terms()}.
     2618 * @return array $retval See {@see bp_set_object_terms()}.
    26552619 */
    26562620function bp_set_member_type( $user_id, $member_type, $append = false ) {
     
    26882652 * @param int    $user_id     ID of the user.
    26892653 * @param string $member_type Member Type.
    2690  *
    26912654 * @return bool|WP_Error
    26922655 */
     
    27222685 * @since 2.2.0
    27232686 *
    2724  * @param int               $user_id ID of the user.
    2725  * @param bool              $single  Optional. Whether to return a single type string. If multiple types are found
    2726  *                                   for the user, the oldest one will be returned. Default: true.
    2727  *
     2687 * @param int  $user_id ID of the user.
     2688 * @param bool $single  Optional. Whether to return a single type string. If multiple types are found
     2689 *                      for the user, the oldest one will be returned. Default: true.
    27282690 * @return string|array|bool On success, returns a single member type (if $single is true) or an array of member
    27292691 *                           types (if $single is false). Returns false on failure.
     
    27692731 * @param int    $user_id     $user_id ID of the user.
    27702732 * @param string $member_type Member Type.
    2771  *
    27722733 * @return bool Whether the user has the given member type.
    27732734 */
     
    27942755 *
    27952756 * @param int $user_id ID of the user.
    2796  *
    2797  * @return See {@see bp_set_member_type()}.
     2757 * @return array $value See {@see bp_set_member_type()}.
    27982758 */
    27992759function bp_remove_member_type_on_user_delete( $user_id ) {
  • trunk/src/bp-members/bp-members-loader.php

    r10248 r10322  
    1010defined( 'ABSPATH' ) || exit;
    1111
     12/**
     13 * Defines the BuddyPress Members Component.
     14 */
    1215class BP_Members_Component extends BP_Component {
    1316
     
    1720     * @see bp_register_member_type()
    1821     *
    19      * @since  2.2.0
    20      * @var    array
     22     * @since 2.2.0
     23     * @var array
    2124     */
    2225    public $types = array();
     
    4851    public function includes( $includes = array() ) {
    4952
    50         // Always include these files
     53        // Always include these files.
    5154        $includes = array(
    5255            'actions',
     
    6568        }
    6669
    67         // Include these only if in admin
     70        // Include these only if in admin.
    6871        if ( is_admin() ) {
    6972            $includes[] = 'admin';
     
    8891        $bp = buddypress();
    8992
    90         /** Component Globals *************************************************/
    91 
    92         // Define a slug, as a fallback for backpat
     93        /** Component Globals ************************************************
     94         */
     95
     96        // Define a slug, as a fallback for backpat.
    9397        if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
    9498            define( 'BP_MEMBERS_SLUG', $this->id );
    9599        }
    96100
    97         // Override any passed args
     101        // Override any passed args.
    98102        $args = array(
    99103            'slug'            => BP_MEMBERS_SLUG,
     
    110114        parent::setup_globals( $args );
    111115
    112         /** Logged in user ****************************************************/
     116        /** Logged in user ***************************************************
     117         */
    113118
    114119        // The core userdata of the user who is currently logged in.
    115120        $bp->loggedin_user->userdata       = bp_core_get_core_userdata( bp_loggedin_user_id() );
    116121
    117         // Fetch the full name for the logged in user
     122        // Fetch the full name for the logged in user.
    118123        $bp->loggedin_user->fullname       = isset( $bp->loggedin_user->userdata->display_name ) ? $bp->loggedin_user->userdata->display_name : '';
    119124
    120         // Hits the DB on single WP installs so get this separately
     125        // Hits the DB on single WP installs so get this separately.
    121126        $bp->loggedin_user->is_super_admin = $bp->loggedin_user->is_site_admin = is_super_admin( bp_loggedin_user_id() );
    122127
    123         // The domain for the user currently logged in. eg: http://example.com/members/andy
     128        // The domain for the user currently logged in. eg: http://example.com/members/andy.
    124129        $bp->loggedin_user->domain         = bp_core_get_user_domain( bp_loggedin_user_id() );
    125130
    126         /** Displayed user ****************************************************/
    127 
    128         // The core userdata of the user who is currently being displayed
     131        /** Displayed user ***************************************************
     132         */
     133
     134        // The core userdata of the user who is currently being displayed.
    129135        $bp->displayed_user->userdata = bp_core_get_core_userdata( bp_displayed_user_id() );
    130136
    131         // Fetch the full name displayed user
     137        // Fetch the full name displayed user.
    132138        $bp->displayed_user->fullname = isset( $bp->displayed_user->userdata->display_name ) ? $bp->displayed_user->userdata->display_name : '';
    133139
    134         // The domain for the user currently being displayed
     140        // The domain for the user currently being displayed.
    135141        $bp->displayed_user->domain   = bp_core_get_user_domain( bp_displayed_user_id() );
    136142
    137         /** Signup ************************************************************/
     143        /** Signup ***********************************************************
     144         */
    138145
    139146        $bp->signup = new stdClass;
    140147
    141         /** Profiles Fallback *************************************************/
     148        /** Profiles Fallback ************************************************
     149         */
    142150
    143151        if ( ! bp_is_active( 'xprofile' ) ) {
     
    156164        $bp = buddypress();
    157165
    158         /** Default Profile Component *****************************************/
     166        /** Default Profile Component ****************************************
     167         */
    159168
    160169        if ( defined( 'BP_DEFAULT_COMPONENT' ) && BP_DEFAULT_COMPONENT ) {
     
    168177        }
    169178
    170         /** Canonical Component Stack *****************************************/
     179        /** Canonical Component Stack ****************************************
     180         */
    171181
    172182        if ( bp_displayed_user_id() ) {
     
    185195            }
    186196
    187             // Looking at the single member root/home, so assume the default
     197            // Looking at the single member root/home, so assume the default.
    188198            if ( ! bp_current_component() ) {
    189199                $bp->current_component = $bp->default_component;
    190200
    191             // The canonical URL will not contain the default component
     201            // The canonical URL will not contain the default component.
    192202            } elseif ( bp_is_current_component( $bp->default_component ) && ! bp_current_action() ) {
    193203                unset( $bp->canonical_stack['component'] );
    194204            }
    195205
    196             // if we're on a spammer's profile page, only users with the 'bp_moderate' cap
    197             // can view subpages on the spammer's profile
     206            // If we're on a spammer's profile page, only users with the 'bp_moderate' cap
     207            // can view subpages on the spammer's profile.
    198208            //
    199209            // users without the cap trying to access a spammer's subnav page will get
     
    220230    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    221231
    222         // Bail if XProfile component is active
     232        // Bail if XProfile component is active.
    223233        if ( bp_is_active( 'xprofile' ) ) {
    224234            return;
    225235        }
    226236
    227         // Don't set up navigation if there's no member
     237        // Don't set up navigation if there's no member.
    228238        if ( ! is_user_logged_in() && ! bp_is_user() ) {
    229239            return;
    230240        }
    231241
    232         // Determine user to use
     242        // Determine user to use.
    233243        if ( bp_displayed_user_domain() ) {
    234244            $user_domain = bp_displayed_user_domain();
     
    242252        $profile_link = trailingslashit( $user_domain . $slug );
    243253
    244         // Setup the main navigation
     254        // Setup the main navigation.
    245255        $main_nav = array(
    246256            'name'                => _x( 'Profile', 'Member profile main navigation', 'buddypress' ),
     
    252262        );
    253263
    254         // Setup the subnav items for the member profile
     264        // Setup the subnav items for the member profile.
    255265        $sub_nav[] = array(
    256266            'name'            => _x( 'View', 'Member profile view', 'buddypress' ),
     
    292302    public function setup_cache_groups() {
    293303
    294         // Global groups
     304        // Global groups.
    295305        wp_cache_add_global_groups( array(
    296306            'bp_last_activity',
  • trunk/src/bp-members/bp-members-screens.php

    r10276 r10322  
    6969        return;
    7070
    71     // Not a directory
     71    // Not a directory.
    7272    bp_update_is_directory( false, 'register' );
    7373
    74     // If the user is logged in, redirect away from here
     74    // If the user is logged in, redirect away from here.
    7575    if ( is_user_logged_in() ) {
    7676
     
    9696        $bp->signup->step = 'registration-disabled';
    9797
    98     // If the signup page is submitted, validate and save
     98    // If the signup page is submitted, validate and save.
    9999    } elseif ( isset( $_POST['signup_submit'] ) && bp_verify_nonce_request( 'bp_new_signup' ) ) {
    100100
     
    106106        do_action( 'bp_signup_pre_validate' );
    107107
    108         // Check the base account details for problems
     108        // Check the base account details for problems.
    109109        $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
    110110
    111         // If there are errors with account details, set them for display
     111        // If there are errors with account details, set them for display.
    112112        if ( !empty( $account_details['errors']->errors['user_name'] ) )
    113113            $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
     
    116116            $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
    117117
    118         // Check that both password fields are filled in
     118        // Check that both password fields are filled in.
    119119        if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
    120120            $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' );
    121121
    122         // Check that the passwords match
     122        // Check that the passwords match.
    123123        if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] )
    124124            $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' );
     
    127127        $bp->signup->email = $_POST['signup_email'];
    128128
    129         // Now we've checked account details, we can check profile information
     129        // Now we've checked account details, we can check profile information.
    130130        if ( bp_is_active( 'xprofile' ) ) {
    131131
    132             // Make sure hidden field is passed and populated
     132            // Make sure hidden field is passed and populated.
    133133            if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) {
    134134
    135                 // Let's compact any profile field info into an array
     135                // Let's compact any profile field info into an array.
    136136                $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    137137
    138                 // Loop through the posted fields formatting any datebox values then validate the field
     138                // Loop through the posted fields formatting any datebox values then validate the field.
    139139                foreach ( (array) $profile_field_ids as $field_id ) {
    140140                    if ( !isset( $_POST['field_' . $field_id] ) ) {
     
    143143                    }
    144144
    145                     // Create errors for required fields without values
     145                    // Create errors for required fields without values.
    146146                    if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST[ 'field_' . $field_id ] ) && ! bp_current_user_can( 'bp_moderate' ) )
    147147                        $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
    148148                }
    149149
    150             // This situation doesn't naturally occur so bounce to website root
     150            // This situation doesn't naturally occur so bounce to website root.
    151151            } else {
    152152                bp_core_redirect( bp_get_root_domain() );
     
    154154        }
    155155
    156         // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled
     156        // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled.
    157157        if ( isset( $_POST['signup_with_blog'] ) ) {
    158158            $active_signup = bp_core_get_root_option( 'registration' );
     
    161161                $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
    162162
    163                 // If there are errors with blog details, set them for display
     163                // If there are errors with blog details, set them for display.
    164164                if ( !empty( $blog_details['errors']->errors['blogname'] ) )
    165165                    $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
     
    180180        if ( !empty( $bp->signup->errors ) ) {
    181181            foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) {
    182                 // addslashes() and stripslashes() to avoid create_function()
    183                 // syntax errors when the $error_message contains quotes
     182                /*
     183                 * The addslashes() and stripslashes() used to avoid create_function()
     184                 * syntax errors when the $error_message contains quotes.
     185                 */
    184186
    185187                /**
     
    200202            if ( 'none' != $active_signup ) {
    201203
    202                 // Make sure the extended profiles module is enabled
     204                // Make sure the extended profiles module is enabled.
    203205                if ( bp_is_active( 'xprofile' ) ) {
    204                     // Let's compact any profile field info into usermeta
     206                    // Let's compact any profile field info into usermeta.
    205207                    $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    206208
    207                     // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile()
     209                    // Loop through the posted fields formatting any datebox values then add to usermeta - @todo This logic should be shared with the same in xprofile_screen_edit_profile().
    208210                    foreach ( (array) $profile_field_ids as $field_id ) {
    209211                        if ( ! isset( $_POST['field_' . $field_id] ) ) {
    210212
    211213                            if ( ! empty( $_POST['field_' . $field_id . '_day'] ) && ! empty( $_POST['field_' . $field_id . '_month'] ) && ! empty( $_POST['field_' . $field_id . '_year'] ) ) {
    212                                 // Concatenate the values
     214                                // Concatenate the values.
    213215                                $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
    214216
    215                                 // Turn the concatenated value into a timestamp
     217                                // Turn the concatenated value into a timestamp.
    216218                                $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
    217219                            }
     
    225227                    }
    226228
    227                     // Store the profile field ID's in usermeta
     229                    // Store the profile field ID's in usermeta.
    228230                    $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
    229231                }
    230232
    231                 // Hash and store the password
     233                // Hash and store the password.
    232234                $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
    233235
    234                 // If the user decided to create a blog, save those details to usermeta
     236                // If the user decided to create a blog, save those details to usermeta.
    235237                if ( 'blog' == $active_signup || 'all' == $active_signup )
    236238                    $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
     
    245247                $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
    246248
    247                 // Finally, sign up the user and/or blog
     249                // Finally, sign up the user and/or blog.
    248250                if ( isset( $_POST['signup_with_blog'] ) && is_multisite() )
    249251                    $wp_user_id = bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
     
    294296function bp_core_screen_activation() {
    295297
    296     // Bail if not viewing the activation page
     298    // Bail if not viewing the activation page.
    297299    if ( ! bp_is_current_component( 'activate' ) ) {
    298300        return false;
    299301    }
    300302
    301     // If the user is already logged in, redirect away from here
     303    // If the user is already logged in, redirect away from here.
    302304    if ( is_user_logged_in() ) {
    303305
     
    308310            : bp_get_root_domain();
    309311
    310         // Trailing slash it, as we expect these URL's to be
     312        // Trailing slash it, as we expect these URL's to be.
    311313        $redirect_to = trailingslashit( $redirect_to );
    312314
     
    320322        $redirect_to = apply_filters( 'bp_loggedin_activate_page_redirect_to', $redirect_to );
    321323
    322         // Redirect away from the activation page
     324        // Redirect away from the activation page.
    323325        bp_core_redirect( $redirect_to );
    324326    }
    325327
    326     // grab the key (the old way)
     328    // Grab the key (the old way).
    327329    $key = isset( $_GET['key'] ) ? $_GET['key'] : '';
    328330
    329     // grab the key (the new way)
     331    // Grab the key (the new way).
    330332    if ( empty( $key ) ) {
    331333        $key = bp_current_action();
    332334    }
    333335
    334     // Get BuddyPress
     336    // Get BuddyPress.
    335337    $bp = buddypress();
    336338
    337     // we've got a key; let's attempt to activate the signup
     339    // We've got a key; let's attempt to activate the signup.
    338340    if ( ! empty( $key ) ) {
    339341
     
    348350        $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $key ) );
    349351
    350         // If there were errors, add a message and redirect
     352        // If there were errors, add a message and redirect.
    351353        if ( ! empty( $user->errors ) ) {
    352354            bp_core_add_message( $user->get_error_message(), 'error' );
     
    357359
    358360        // Check if the signup avatar folder exists. If it does, move the folder to
    359         // the BP user avatars directory
     361        // the BP user avatars directory.
    360362        if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) {
    361363            @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user );
     
    405407    public function is_members() {
    406408
    407         // Bail if not looking at the members component or a user's page
     409        // Bail if not looking at the members component or a user's page.
    408410        if ( ! bp_is_members_component() && ! bp_is_user() ) {
    409411            return;
    410412        }
    411413
    412         // Members Directory
     414        // Members Directory.
    413415        if ( ! bp_current_action() && ! bp_current_item() ) {
    414416            bp_update_is_directory( true, 'members' );
     
    425427            add_filter( 'bp_replace_the_content',                    array( $this, 'directory_content'    ) );
    426428
    427         // User page
     429        // User page.
    428430        } elseif ( bp_is_user() ) {
    429431
     
    459461     *
    460462     * @param array $templates The templates from bp_get_theme_compat_templates().
    461      *
    462463     * @return array $templates Array of custom templates to look for.
    463464     */
    464465    public function directory_template_hierarchy( $templates = array() ) {
    465466
    466         // Set up the template hierarchy
     467        // Set up the template hierarchy.
    467468        $new_templates = array();
    468469        if ( '' !== bp_get_current_member_type() ) {
     
    481482
    482483        // Merge new templates with existing stack
    483         // @see bp_get_theme_compat_templates()
     484        // @see bp_get_theme_compat_templates().
    484485        $templates = array_merge( (array) $new_templates, $templates );
    485486
     
    527528     * @param string $templates The templates from
    528529     *                          bp_get_theme_compat_templates().
    529      *
    530530     * @return array $templates Array of custom templates to look for.
    531531     */
    532532    public function single_template_hierarchy( $templates ) {
    533         // Setup some variables we're going to reference in our custom templates
     533        // Setup some variables we're going to reference in our custom templates.
    534534        $user_nicename = buddypress()->displayed_user->userdata->user_nicename;
    535535
     
    550550
    551551        // Merge new templates with existing stack
    552         // @see bp_get_theme_compat_templates()
     552        // @see bp_get_theme_compat_templates().
    553553        $templates = array_merge( (array) $new_templates, $templates );
    554554
     
    612612    public function is_registration() {
    613613
    614         // Bail if not looking at the registration or activation page
     614        // Bail if not looking at the registration or activation page.
    615615        if ( ! bp_is_register_page() && ! bp_is_activation_page() ) {
    616616            return;
    617617        }
    618618
    619         // Not a directory
     619        // Not a directory.
    620620        bp_update_is_directory( false, 'register' );
    621621
    622         // Setup actions
     622        // Setup actions.
    623623        add_filter( 'bp_get_buddypress_template',                array( $this, 'template_hierarchy' ) );
    624624        add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'dummy_post'    ) );
     
    637637     *
    638638     * @param string $templates The templates from bp_get_theme_compat_templates().
    639      *
    640639     * @return array $templates Array of custom templates to look for.
    641640     */
     
    658657
    659658        // Merge new templates with existing stack
    660         // @see bp_get_theme_compat_templates()
     659        // @see bp_get_theme_compat_templates().
    661660        $templates = array_merge( (array) $new_templates, $templates );
    662661
     
    670669     */
    671670    public function dummy_post() {
    672         // Registration page
     671        // Registration page.
    673672        if ( bp_is_register_page() ) {
    674673            $title = __( 'Create an Account', 'buddypress' );
     
    678677            }
    679678
    680         // Activation page
     679        // Activation page.
    681680        } else {
    682681            $title = __( 'Activate Your Account', 'buddypress' );
  • trunk/src/bp-members/bp-members-template.php

    r10248 r10322  
    433433             */
    434434            do_action('member_loop_end');
    435             // Do some cleaning up after the loop
     435            // Do some cleaning up after the loop.
    436436            $this->rewind_members();
    437437        }
     
    455455        $this->member      = $this->next_member();
    456456
    457         // loop has just started
     457        // Loop has just started.
    458458        if ( 0 == $this->current_member ) {
    459459
     
    535535    global $members_template;
    536536
    537     // Default user ID
     537    // Default user ID.
    538538    $user_id = 0;
    539539
    540     // User filtering
     540    // User filtering.
    541541    if ( bp_is_user_friends() && ! bp_is_user_friend_requests() ) {
    542542        $user_id = bp_displayed_user_id();
     
    559559    }
    560560
    561     // type: active ( default ) | random | newest | popular | online | alphabetical
     561    // Type: active ( default ) | random | newest | popular | online | alphabetical.
    562562    $r = bp_parse_args( $args, array(
    563563        'type'                => 'active',
     
    566566        'max'                 => false,
    567567
    568         'page_arg'            => 'upage',  // See https://buddypress.trac.wordpress.org/ticket/3679
    569 
    570         'include'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users
    571         'exclude'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
    572 
    573         'user_id'             => $user_id, // Pass a user_id to only show friends of this user
     568        'page_arg'            => 'upage',  // See https://buddypress.trac.wordpress.org/ticket/3679.
     569
     570        'include'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users.
     571        'exclude'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users.
     572
     573        'user_id'             => $user_id, // Pass a user_id to only show friends of this user.
    574574        'member_type'         => $member_type,
    575575        'member_type__in'     => '',
     
    577577        'search_terms'        => $search_terms_default,
    578578
    579         'meta_key'            => false,    // Only return users with this usermeta
    580         'meta_value'          => false,    // Only return users where the usermeta value matches. Requires meta_key
     579        'meta_key'            => false,    // Only return users with this usermeta.
     580        'meta_value'          => false,    // Only return users where the usermeta value matches. Requires meta_key.
    581581
    582582        'populate_extras'     => true      // Fetch usermeta? Friend count, last active etc.
     
    592592    }
    593593
    594     // Set per_page to max if max is larger than per_page
     594    // Set per_page to max if max is larger than per_page.
    595595    if ( !empty( $r['max'] ) && ( $r['per_page'] > $r['max'] ) ) {
    596596        $r['per_page'] = $r['max'];
    597597    }
    598598
    599     // Query for members and populate $members_template global
     599    // Query for members and populate $members_template global.
    600600    $members_template = new BP_Core_Members_Template(
    601601        $r['type'],
     
    761761 * @since 1.7.0
    762762 *
    763  * @param array $classes Array of custom classes
     763 * @param array $classes Array of custom classes.
    764764 */
    765765function bp_member_class( $classes = array() ) {
     
    771771     * @since 1.7.0
    772772     *
    773      * @param array $classes Array of custom classes
     773     * @param array $classes Array of custom classes.
    774774     *
    775775     * @return string Row class of the member
     
    778778        global $members_template;
    779779
    780         // Add even/odd classes, but only if there's more than 1 member
     780        // Add even/odd classes, but only if there's more than 1 member.
    781781        if ( $members_template->member_count > 1 ) {
    782782            $pos_in_loop = (int) $members_template->current_member;
    783783            $classes[]   = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
    784784
    785         // If we've only one member in the loop, don't bother with odd and even
     785        // If we've only one member in the loop, don't bother with odd and even.
    786786        } else {
    787787            $classes[] = 'bp-single-member';
    788788        }
    789789
    790         // Maybe add 'is-online' class
     790        // Maybe add 'is-online' class.
    791791        if ( ! empty( $members_template->member->last_activity ) ) {
    792792
    793             // Calculate some times
     793            // Calculate some times.
    794794            $current_time  = strtotime( bp_core_current_time() );
    795795            $last_activity = strtotime( $members_template->member->last_activity );
     
    802802        }
    803803
    804         // Add current user class
     804        // Add current user class.
    805805        if ( bp_loggedin_user_id() === (int) $members_template->member->id ) {
    806806            $classes[] = 'is-current-user';
     
    925925     * @since 1.2.0
    926926     *
    927      * @param string $value Formatted HTML <img> element,
    928      *                      or raw avatar URL based on $html arg.
     927     * @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg.
    929928     */
    930929    echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
     
    972971         * @since 1.2.0
    973972         *
    974          * @param string $value Formatted HTML <img> element,
    975          *                      or raw avatar URL based on $html arg.
     973         * @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg.
    976974         */
    977975        return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
     
    10391037        global $members_template;
    10401038
    1041         // Generally, this only fires when xprofile is disabled
     1039        // Generally, this only fires when xprofile is disabled.
    10421040        if ( empty( $members_template->member->fullname ) ) {
    1043             // Our order of preference for alternative fullnames
     1041            // Our order of preference for alternative fullnames.
    10441042            $name_stack = array(
    10451043                'display_name',
     
    10501048            foreach ( $name_stack as $source ) {
    10511049                if ( !empty( $members_template->member->{$source} ) ) {
    1052                     // When a value is found, set it as fullname and be done
    1053                     // with it
     1050                    // When a value is found, set it as fullname and be done with it.
    10541051                    $members_template->member->fullname = $members_template->member->{$source};
    10551052                    break;
     
    10951092        global $members_template;
    10961093
    1097         // Parse the activity format
     1094        // Parse the activity format.
    10981095        $r = bp_parse_args( $args, array(
    10991096            'active_format' => true
    11001097        ) );
    11011098
    1102         // Backwards compatibility for anyone forcing a 'true' active_format
     1099        // Backwards compatibility for anyone forcing a 'true' active_format.
    11031100        if ( true === $r['active_format'] ) {
    11041101            $r['active_format'] = __( 'active %s', 'buddypress' );
    11051102        }
    11061103
    1107         // Member has logged in at least one time
     1104        // Member has logged in at least one time.
    11081105        if ( isset( $members_template->member->last_activity ) ) {
    11091106
    1110             // Backwards compatibility for pre 1.5 'ago' strings
     1107            // Backwards compatibility for pre 1.5 'ago' strings.
    11111108            $last_activity = ! empty( $r['active_format'] )
    11121109                ? bp_core_get_last_activity( $members_template->member->last_activity, $r['active_format'] )
    11131110                : bp_core_time_since( $members_template->member->last_activity );
    11141111
    1115         // Member has never logged in or been active
     1112        // Member has never logged in or been active.
    11161113        } else {
    11171114            $last_activity = __( 'Never active', 'buddypress' );
     
    11321129 * Output the latest update of the current member in the loop.
    11331130 *
    1134  * @param array|string $args
     1131 * @param array|string $args Array of arguments for latest update.
    11351132 */
    11361133function bp_member_latest_update( $args = '' ) {
     
    12241221        }
    12251222
    1226         // Declare local variables
     1223        // Declare local variables.
    12271224        $data = false;
    12281225
    1229         // Guess at default $user_id
     1226        // Guess at default $user_id.
    12301227        $default_user_id = 0;
    12311228        if ( ! empty( $members_template->member->id ) ) {
     
    12421239        $r = wp_parse_args( $args, $defaults );
    12431240
    1244         // If we're in a members loop, get the data from the global
     1241        // If we're in a members loop, get the data from the global.
    12451242        if ( ! empty( $members_template->member->profile_data ) ) {
    12461243            $profile_data = $members_template->member->profile_data;
    12471244        }
    12481245
    1249         // Otherwise query for the data
     1246        // Otherwise query for the data.
    12501247        if ( empty( $profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) ) {
    12511248            $profile_data = BP_XProfile_ProfileData::get_all_for_user( $r['user_id'] );
     
    12531250
    12541251        // If we're in the members loop, but the profile data has not
    1255         // been loaded into the global, cache it there for later use
     1252        // been loaded into the global, cache it there for later use.
    12561253        if ( ! empty( $members_template->member ) && empty( $members_template->member->profile_data ) ) {
    12571254            $members_template->member->profile_data = $profile_data;
    12581255        }
    12591256
    1260         // Get the data for the specific field requested
     1257        // Get the data for the specific field requested.
    12611258        if ( ! empty( $profile_data ) && ! empty( $profile_data[ $r['field'] ]['field_type'] ) && ! empty( $profile_data[ $r['field'] ]['field_data'] ) ) {
    12621259            $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] );
     
    13971394    $bp = buddypress();
    13981395
    1399     // Loop through each navigation item
     1396    // Loop through each navigation item.
    14001397    foreach( (array) $bp->bp_nav as $nav_item ) {
    14011398
     
    14231420        }
    14241421
    1425         // echo out the final list item
     1422        // Echo out the final list item.
    14261423        echo apply_filters_ref_array( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], array( '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item ) );
    14271424    }
    14281425
    1429     // Always add a log out list item to the end of the navigation
     1426    // Always add a log out list item to the end of the navigation.
    14301427    $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( bp_get_root_domain() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    14311428
     
    14901487 * @see bp_get_loggedin_user_avatar() for a description of params.
    14911488 *
    1492  * @param array|string $args
     1489 * @param array|string $args Array of arguments for logged in user avatar.
    14931490 */
    14941491function bp_loggedin_user_avatar( $args = '' ) {
     
    15391536 * @see bp_get_displayed_user_avatar() for a description of params.
    15401537 *
    1541  * @param array|string $args
     1538 * @param array|string $args Array of arguments for displayed user avatar.
    15421539 */
    15431540function bp_displayed_user_avatar( $args = '' ) {
     
    15971594        $bp = buddypress();
    15981595
    1599         // If displayed user exists, return email address
     1596        // If displayed user exists, return email address.
    16001597        if ( isset( $bp->displayed_user->userdata->user_email ) )
    16011598            $retval = $bp->displayed_user->userdata->user_email;
     
    16351632     *
    16361633     * @param int $user_id ID of the user. Default: displayed user ID.
    1637      *
    16381634     * @return string
    16391635     */
     
    16731669    function bp_get_user_firstname( $name = false ) {
    16741670
    1675         // Try to get displayed user
     1671        // Try to get displayed user.
    16761672        if ( empty( $name ) )
    16771673            $name = bp_get_displayed_user_fullname();
    16781674
    1679         // Fall back on logged in user
     1675        // Fall back on logged in user.
    16801676        if ( empty( $name ) )
    16811677            $name = bp_get_loggedin_user_fullname();
     
    19331929 * @uses bp_get_signup_slug() To make sure there is a slug assigned to the page.
    19341930 * @uses bp_locate_template() To make sure a template exists to provide output.
     1931 *
    19351932 * @return bool True if page and template exist, false if not.
    19361933 */
     
    21482145        global $current_site;
    21492146
    2150         // In case plugins are still using this filter
     2147        // In case plugins are still using this filter.
    21512148        $subdomain_base = apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
    21522149
     
    22322229        $bp = buddypress();
    22332230
    2234         // Check if signup_avatar_dir is passed
     2231        // Check if signup_avatar_dir is passed.
    22352232        if ( !empty( $_POST['signup_avatar_dir'] ) )
    22362233            $signup_avatar_dir = $_POST['signup_avatar_dir'];
    22372234
    2238         // If not, check if global is set
     2235        // If not, check if global is set.
    22392236        elseif ( !empty( $bp->signup->avatar_dir ) )
    22402237            $signup_avatar_dir = $bp->signup->avatar_dir;
    22412238
    2242         // If not, set false
     2239        // If not, set false.
    22432240        else
    22442241            $signup_avatar_dir = false;
     
    23052302        extract( $r, EXTR_SKIP );
    23062303
    2307         // Avatar DIR is found
     2304        // Avatar DIR is found.
    23082305        if ( $signup_avatar_dir = bp_get_signup_avatar_dir_value() ) {
    23092306            $gravatar_img = bp_core_fetch_avatar( array(
     
    23182315            ) );
    23192316
    2320         // No avatar DIR was found
     2317        // No avatar DIR was found.
    23212318        } else {
    23222319
    2323             // Set default gravatar type
     2320            // Set default gravatar type.
    23242321            if ( empty( $bp->grav_default->user ) )
    23252322                $default_grav = 'wavatar';
     
    24352432    function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) {
    24362433
    2437         // Must be displayed user
     2434        // Must be displayed user.
    24382435        if ( !bp_displayed_user_id() )
    24392436            return;
     
    24412438        $bp = buddypress();
    24422439
    2443         // Append $action to $url if there is no $type
     2440        // Append $action to $url if there is no $type.
    24442441        if ( !empty( $action ) )
    24452442            $url = bp_displayed_user_domain() . $bp->{$component}->slug . '/' . $action;
     
    24472444            $url = bp_displayed_user_domain() . $bp->{$component}->slug;
    24482445
    2449         // Add a slash at the end of our user url
     2446        // Add a slash at the end of our user url.
    24502447        $url = trailingslashit( $url );
    24512448
    2452         // Add possible query arg
     2449        // Add possible query arg.
    24532450        if ( !empty( $query_args ) && is_array( $query_args ) )
    24542451            $url = add_query_arg( $query_args, $url );
     
    24602457            $url = wp_nonce_url( $url, $nonce );
    24612458
    2462         // Return the url, if there is one
     2459        // Return the url, if there is one.
    24632460        if ( !empty( $url ) )
    24642461            return $url;
  • trunk/src/bp-members/bp-members-widgets.php

    r10276 r10322  
    3535    public function __construct() {
    3636
    37         // Setup widget name & description
     37        // Setup widget name & description.
    3838        $name        = _x( '(BuddyPress) Members', 'widget name', 'buddypress' );
    3939        $description = __( 'A dynamic list of recently active, popular, and newest members', 'buddypress' );
    4040
    41         // Call WP_Widget constructor
     41        // Call WP_Widget constructor.
    4242        parent::__construct( false, $name, array(
    4343            'description' => $description,
     
    4545        ) );
    4646
    47         // Maybe enqueue JS for widget
     47        // Maybe enqueue JS for widget.
    4848        if ( is_active_widget( false, false, $this->id_base ) && ! is_admin() && ! is_network_admin() ) {
    4949            wp_enqueue_script( 'bp-widget-members' );
     
    6161    public function widget( $args, $instance ) {
    6262
    63         // Get widget settings
     63        // Get widget settings.
    6464        $settings = $this->parse_settings( $instance );
    6565
     
    8686        $separator = apply_filters( 'bp_members_widget_separator', '|' );
    8787
    88         // Output before widget HTMl, title (and maybe content before & after it)
     88        // Output before widget HTMl, title (and maybe content before & after it).
    8989        echo $args['before_widget']
    9090           . $args['before_title']
     
    9292           . $args['after_title'];
    9393
    94         // Setup args for querying members
     94        // Setup args for querying members.
    9595        $members_args = array(
    9696            'user_id'         => 0,
     
    165165     * @param array $new_instance The new instance options.
    166166     * @param array $old_instance The old instance options.
    167      *
    168      * @return array $instance     The parsed options to be saved.
     167     * @return array $instance The parsed options to be saved.
    169168     */
    170169    public function update( $new_instance, $old_instance ) {
     
    184183     * @param array $instance Widget instance settings.
    185184     *
    186      * @return string
     185     * @return void
    187186     */
    188187    public function form( $instance ) {
    189188
    190         // Get widget settings
     189        // Get widget settings.
    191190        $settings       = $this->parse_settings( $instance );
    192191        $title          = strip_tags( $settings['title'] );
     
    233232     * @since 2.3.0
    234233     *
     234     * @uses bp_parse_args() To merge widget settings into defaults.
     235     *
    235236     * @param array $instance Widget instance settings.
    236      *
    237      * @uses bp_parse_args() To merge widget settings into defaults.
    238      *
    239237     * @return array
    240238     */
     
    278276    public function widget( $args, $instance ) {
    279277
    280         // Get widget settings
     278        // Get widget settings.
    281279        $settings = $this->parse_settings( $instance );
    282280
     
    298296           . $args['after_title'];
    299297
    300         // Setup args for querying members
     298        // Setup args for querying members.
    301299        $members_args = array(
    302300            'user_id'         => 0,
     
    338336     * @param array $new_instance The new instance options.
    339337     * @param array $old_instance The old instance options.
    340      *
    341      * @return array $instance     The parsed options to be saved.
     338     * @return array $instance The parsed options to be saved.
    342339     */
    343340    public function update( $new_instance, $old_instance ) {
     
    353350     *
    354351     * @param array $instance Widget instance settings.
    355      *
    356      * @return string
     352     * @return void
    357353     */
    358354    public function form( $instance ) {
    359355
    360         // Get widget settings
     356        // Get widget settings.
    361357        $settings    = $this->parse_settings( $instance );
    362358        $title       = strip_tags( $settings['title'] );
     
    385381     * @since 2.3.0
    386382     *
     383     * @uses bp_parse_args() To merge widget settings into defaults.
     384     *
    387385     * @param array $instance Widget instance settings.
    388      *
    389      * @uses bp_parse_args() To merge widget settings into defaults.
    390      *
    391386     * @return array
    392387     */
     
    428423    public function widget( $args, $instance ) {
    429424
    430         // Get widget settings
     425        // Get widget settings.
    431426        $settings = $this->parse_settings( $instance );
    432427
     
    448443           . $args['after_title'];
    449444
    450         // Setup args for querying members
     445        // Setup args for querying members.
    451446        $members_args = array(
    452447            'user_id'         => 0,
     
    488483     * @param array $new_instance The new instance options.
    489484     * @param array $old_instance The old instance options.
    490      *
    491485     * @return array $instance The parsed options to be saved.
    492486     */
     
    503497     *
    504498     * @param array $instance Widget instance settings.
    505      *
    506      * @return string
     499     * @return void
    507500     */
    508501    public function form( $instance ) {
    509502
    510         // Get widget settings
     503        // Get widget settings.
    511504        $settings    = $this->parse_settings( $instance );
    512505        $title       = strip_tags( $settings['title'] );
     
    535528     * @since 2.3.0
    536529     *
     530     * @uses bp_parse_args() To merge widget settings into defaults.
     531     *
    537532     * @param array $instance Widget instance settings.
    538      *
    539      * @uses bp_parse_args() To merge widget settings into defaults.
    540      *
    541533     * @return array
    542534     */
     
    560552    check_ajax_referer( 'bp_core_widget_members' );
    561553
    562     // Setup some variables to check
     554    // Setup some variables to check.
    563555    $filter      = ! empty( $_POST['filter']      ) ? $_POST['filter']                : 'recently-active-members';
    564556    $max_members = ! empty( $_POST['max-members'] ) ? absint( $_POST['max-members'] ) : 5;
    565557
    566     // Determine the type of members query to perform
     558    // Determine the type of members query to perform.
    567559    switch ( $filter ) {
    568560
    569         // Newest activated
     561        // Newest activated.
    570562        case 'newest-members' :
    571563            $type = 'newest';
    572564            break;
    573565
    574         // Popular by friends
     566        // Popular by friends.
    575567        case 'popular-members' :
    576568            if ( bp_is_active( 'friends' ) ) {
     
    581573            break;
    582574
    583         // Default
     575        // Default.
    584576        case 'recently-active-members' :
    585577        default :
     
    588580    }
    589581
    590     // Setup args for querying members
     582    // Setup args for querying members.
    591583    $members_args = array(
    592584        'user_id'         => 0,
     
    598590    );
    599591
    600     // Query for members
     592    // Query for members.
    601593    if ( bp_has_members( $members_args ) ) : ?>
    602         <?php echo '0[[SPLIT]]'; // return valid result. TODO: remove this. ?>
     594        <?php echo '0[[SPLIT]]'; // Return valid result. TODO: remove this. ?>
    603595        <?php while ( bp_members() ) : bp_the_member(); ?>
    604596            <li class="vcard">
  • trunk/src/bp-members/classes/class-bp-signup.php

    r10149 r10322  
    99 */
    1010
     11/**
     12 * Class used to handle Signups.
     13 */
    1114class BP_Signup {
    1215
     
    112115     *
    113116     * @param array $args the argument to retrieve desired signups.
    114      *
    115117     * @return array {
    116118     *     @type array $signups Located signups.
     
    150152        if ( empty( $r['include'] ) ) {
    151153
    152             // Search terms
     154            // Search terms.
    153155            if ( ! empty( $r['usersearch'] ) ) {
    154156                $search_terms_like = '%' . bp_esc_like( $r['usersearch'] ) . '%';
     
    156158            }
    157159
    158             // Activation key
     160            // Activation key.
    159161            if ( ! empty( $r['activation_key'] ) ) {
    160162                $sql['where'][] = $wpdb->prepare( "activation_key = %s", $r['activation_key'] );
    161163            }
    162164
    163             // User login
     165            // User login.
    164166            if ( ! empty( $r['user_login'] ) ) {
    165167                $sql['where'][] = $wpdb->prepare( "user_login = %s", $r['user_login'] );
     
    174176        }
    175177
    176         // Implode WHERE clauses
     178        // Implode WHERE clauses.
    177179        $sql['where'] = 'WHERE ' . implode( ' AND ', $sql['where'] );
    178180
     
    194196
    195197        // Used to calculate a diff between now & last
    196         // time an activation link has been resent
     198        // time an activation link has been resent.
    197199        $now = current_time( 'timestamp', true );
    198200
     
    208210            }
    209211
    210             // Sent date defaults to date of registration
     212            // Sent date defaults to date of registration.
    211213            if ( ! empty( $signup->meta['sent_date'] ) ) {
    212214                $signup->date_sent = $signup->meta['sent_date'];
     
    219221
    220222            /**
    221              * add a boolean in case the last time an activation link
    222              * has been sent happened less than a day ago
     223             * Add a boolean in case the last time an activation link
     224             * has been sent happened less than a day ago.
    223225             */
    224226            if ( $diff < 1 * DAY_IN_SECONDS ) {
     
    258260     * @since 2.0.0
    259261     *
    260      * @param array $args
    261      *
     262     * @param array $args Array of arguments for signup addition.
    262263     * @return int|bool ID of newly created signup on success, false on
    263264     *                  failure.
     
    320321     * @param string $user_email    User email address.
    321322     * @param array  $usermeta      Metadata associated with the signup.
    322      *
    323323     * @return int User id.
    324324     */
     
    338338
    339339        // Update the user status to '2', ie "not activated"
    340         // (0 = active, 1 = spam, 2 = not active)
     340        // (0 = active, 1 = spam, 2 = not active).
    341341        $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET user_status = 2 WHERE ID = %d", $user_id ) );
    342342
     
    347347        delete_user_option( $user_id, 'user_level'   );
    348348
    349         // Set any profile data
     349        // Set any profile data.
    350350        if ( bp_is_active( 'xprofile' ) ) {
    351351            if ( ! empty( $usermeta['profile_field_ids'] ) ) {
     
    360360                    xprofile_set_field_data( $field_id, $user_id, $current_field );
    361361
    362                     // Save the visibility level
     362                    // Save the visibility level.
    363363                    $visibility_level = ! empty( $usermeta['field_' . $field_id . '_visibility'] ) ? $usermeta['field_' . $field_id . '_visibility'] : 'public';
    364364                    xprofile_set_field_visibility_level( $field_id, $user_id, $visibility_level );
     
    383383     *
    384384     * @param int $user_id ID of the user being checked.
    385      *
    386385     * @return int|bool The status if found, otherwise false.
    387386     */
     
    411410     *
    412411     * @param string $key Activation key.
    413      *
    414412     * @return bool True on success, false on failure.
    415413     */
     
    422420
    423421        $activated = $wpdb->update(
    424             // Signups table
     422            // Signups table.
    425423            buddypress()->members->table_name_signups,
    426424            array(
     
    431429                'activation_key' => $key,
    432430            ),
    433             // Data sanitization format
     431            // Data sanitization format.
    434432            array(
    435433                '%d',
    436434                '%s',
    437435            ),
    438             // WHERE sanitization format
     436            // WHERE sanitization format.
    439437            array(
    440438                '%s',
     
    483481     * @since 2.0.0
    484482     *
    485      * @param array $args
    486      *
    487      * @return int The signup id
     483     * @param array $args Array of arguments for the signup update.
     484     * @return int The signup id.
    488485     */
    489486    public static function update( $args = array() ) {
     
    503500
    504501        $wpdb->update(
    505             // Signups table
     502            // Signups table.
    506503            buddypress()->members->table_name_signups,
    507             // Data to update
     504            // Data to update.
    508505            array(
    509506                'meta' => serialize( $r['meta'] ),
    510507            ),
    511             // WHERE
     508            // WHERE.
    512509            array(
    513510                'signup_id' => $r['signup_id'],
    514511            ),
    515             // Data sanitization format
     512            // Data sanitization format.
    516513            array(
    517514                '%s',
    518515            ),
    519             // WHERE sanitization format
     516            // WHERE sanitization format.
    520517            array(
    521518                '%d',
     
    539536     *
    540537     * @param array $signup_ids Single ID or list of IDs to resend.
    541      *
    542538     * @return array
    543539     */
     
    572568            $meta['count_sent'] = $signup->count_sent + 1;
    573569
    574             // Send activation email
     570            // Send activation email.
    575571            if ( is_multisite() ) {
    576572                wpmu_signup_user_notification( $signup->user_login, $signup->user_email, $signup->activation_key, serialize( $meta ) );
    577573            } else {
    578574
    579                 // Check user status before sending email
     575                // Check user status before sending email.
    580576                $user_id = email_exists( $signup->user_email );
    581577
    582578                if ( ! empty( $user_id ) && 2 != self::check_user_status( $user_id ) ) {
    583579
    584                     // Status is not 2, so user's account has been activated
     580                    // Status is not 2, so user's account has been activated.
    585581                    $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
    586582
    587                     // repair signups table
     583                    // Repair signups table.
    588584                    self::validate( $signup->activation_key );
    589585
    590586                    continue;
    591587
    592                 // Send the validation email
     588                // Send the validation email.
    593589                } else {
    594590                    bp_core_signup_send_validation_email( false, $signup->user_email, $signup->activation_key );
     
    596592            }
    597593
    598             // Update metas
     594            // Update metas.
    599595            $result['resent'][] = self::update( array(
    600596                'signup_id' => $signup->signup_id,
     
    629625     *
    630626     * @param array $signup_ids Single ID or list of IDs to activate.
    631      *
    632627     * @return array
    633628     */
     
    670665                if ( empty( $user_id ) ) {
    671666
    672                     // Status is not 2, so user's account has been activated
     667                    // Status is not 2, so user's account has been activated.
    673668                    $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
    674669
    675                     // repair signups table
     670                    // Repair signups table.
    676671                    self::validate( $signup->activation_key );
    677672
    678                 // we have a user id, account is not active, let's delete it
     673                // We have a user id, account is not active, let's delete it.
    679674                } else {
    680675                    $result['errors'][ $signup->signup_id ] = array( $signup->user_login, $user->get_error_message() );
     
    712707     *
    713708     * @param array $signup_ids Single ID or list of IDs to delete.
    714      *
    715709     * @return array
    716710     */
     
    748742                if ( 2 != self::check_user_status( $user_id ) ) {
    749743
    750                     // Status is not 2, so user's account has been activated
     744                    // Status is not 2, so user's account has been activated.
    751745                    $result['errors'][ $signup->signup_id ] = array( $signup->user_login, esc_html__( 'the sign-up has already been activated.', 'buddypress' ) );
    752746
    753                     // repair signups table
     747                    // Repair signups table.
    754748                    self::validate( $signup->activation_key );
    755749
    756                 // we have a user id, account is not active, let's delete it
     750                // We have a user id, account is not active, let's delete it.
    757751                } else {
    758752                    bp_core_delete_account( $user_id );
     
    762756            if ( empty( $result['errors'][ $signup->signup_id ] ) ) {
    763757                $wpdb->delete(
    764                     // Signups table
     758                    // Signups table.
    765759                    buddypress()->members->table_name_signups,
    766                     // Where
     760                    // Where.
    767761                    array( 'signup_id' => $signup->signup_id, ),
    768                     // WHERE sanitization format
     762                    // WHERE sanitization format.
    769763                    array( '%d', )
    770764                );
Note: See TracChangeset for help on using the changeset viewer.