Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/29/2014 05:01:17 PM (10 years ago)
Author:
johnjamesjacoby
Message:

First pass at introducing BuddyPress profile editing to /wp-admin:

  • New bp-members-admin.php and accompanying assets to handle the initial admin page creation (outside of XProfile).
  • New stats template functions in Blogs, Friends, and Groups components, to provide additional meta data about a members community involvement.
  • Modifies some existing XProfile admin/template/filters to make it more accommodating to querying for profile data outside of BuddyPress's traditional displayed_user context.
  • Props imath, boonebgorges, johnjamesjacoby. Fixes #5197.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-template.php

    r7751 r7764  
    31553155            return $url;
    31563156    }
     3157
     3158/** Stats **********************************************************************/
     3159
     3160/**
     3161 * Display the number of groups in user's profile.
     3162 *
     3163 * @since BuddyPress (2.0.0)
     3164 *
     3165 * @param array $args before|after|user_id
     3166 * @uses bp_groups_get_profile_stats() to get the stats
     3167 */
     3168function bp_groups_profile_stats( $args = '' ) {
     3169    echo bp_groups_get_profile_stats( $args );
     3170}
     3171add_action( 'bp_members_admin_user_stats', 'bp_groups_profile_stats', 8, 1 );
     3172
     3173/**
     3174 * Return the number of groups in user's profile.
     3175 *
     3176 * @since BuddyPress (2.0.0)
     3177 *
     3178 * @param array $args before|after|user_id
     3179 * @return string HTML for stats output.
     3180 */
     3181function bp_groups_get_profile_stats( $args = '' ) {
     3182
     3183    // Parse the args
     3184    $r = bp_parse_args( $args, array(
     3185        'before'  => '<li class="bp-groups-profile-stats">',
     3186        'after'   => '</li>',
     3187        'user_id' => bp_displayed_user_id(),
     3188        'groups'  => 0,
     3189        'output'  => ''
     3190    ), 'groups_get_profile_stats' );
     3191
     3192    // Allow completely overloaded output
     3193    if ( empty( $r['output'] ) ) {
     3194
     3195        // Only proceed if a user ID was passed
     3196        if ( ! empty( $r['user_id'] ) ) {
     3197
     3198            // Get the user groups
     3199            if ( empty( $r['groups'] ) ) {
     3200                $r['groups'] = absint( bp_get_total_group_count_for_user( $r['user_id'] ) );
     3201            }
     3202
     3203            // If groups exist, show some formatted output
     3204            $r['output'] = $r['before'] . sprintf( _n( '1 group', '<strong>%s</strong> groups', $r['groups'], 'buddypress' ), $r['groups'] ) . $r['after'];
     3205        }
     3206    }
     3207
     3208    // Filter and return
     3209    return apply_filters( 'bp_groups_get_profile_stats', $r['output'], $r );
     3210}
Note: See TracChangeset for help on using the changeset viewer.