bp_members_admin_bar_user_admin_menu()

Add the User Admin top-level menu to user pages.

Description

Source

File: bp-members/bp-members-adminbar.php

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
function bp_members_admin_bar_user_admin_menu() {
    global $wp_admin_bar;
 
    // Only show if viewing a user.
    if ( !bp_is_user() )
        return false;
 
    // Don't show this menu to non site admins or if you're viewing your own profile.
    if ( !current_user_can( 'edit_users' ) || bp_is_my_profile() )
        return false;
 
    $bp = buddypress();
 
    // Unique ID for the 'My Account' menu.
    $bp->user_admin_menu_id = 'user-admin';
 
    $user = get_userdata( bp_displayed_user_id() );
    $link = BP_Core_Members_Switching::maybe_switch_url( $user );
 
    // Add the top-level User Admin button.
    $wp_admin_bar->add_menu( array(
        'id'    => $bp->user_admin_menu_id,
        'title' => __( 'Edit Member', 'buddyboss' ),
        'href'  => add_query_arg( [
            'redirect_to' => urlencode( bp_get_members_component_link( 'profile', 'edit' ) ),
        ], $link )
    ) );
 
    if ( bp_is_active( 'xprofile' ) ) {
        // User Admin > Edit this user's profile.
        $wp_admin_bar->add_menu( array(
            'parent' => $bp->user_admin_menu_id,
            'id'     => $bp->user_admin_menu_id . '-edit-profile',
            'title'  => __( 'Edit Profile', 'buddyboss' ),
            'href'   => add_query_arg( [
                'redirect_to' => urlencode( bp_get_members_component_link( 'profile', 'edit' ) ),
            ], $link )
        ) );
 
        // User Admin > Edit this user's avatar.
        if ( buddypress()->avatar->show_avatars ) {
            $wp_admin_bar->add_menu( array(
                'parent' => $bp->user_admin_menu_id,
                'id'     => $bp->user_admin_menu_id . '-change-avatar',
                'title'  => __( 'Edit Profile Photo', 'buddyboss' ),
                'href'   => add_query_arg( [
                    'redirect_to' => urlencode( bp_get_members_component_link( 'profile', 'change-avatar' ) ),
                ], $link )
            ) );
        }
 
        // User Admin > Edit this user's cover photo.
        if ( bp_displayed_user_use_cover_image_header() ) {
            $wp_admin_bar->add_menu( array(
                'parent' => $bp->user_admin_menu_id,
                'id'     => $bp->user_admin_menu_id . '-change-cover-image',
                'title'  => __( 'Edit Cover Photo', 'buddyboss' ),
                'href'   => add_query_arg( [
                    'redirect_to' => urlencode( bp_get_members_component_link( 'profile', 'change-cover-image' ) ),
                ], $link )
            ) );
        }
 
    }
 
    if ( bp_is_active( 'settings' ) ) {
        // User Admin > Spam/unspam.
//      $wp_admin_bar->add_menu( array(
//          'parent' => $bp->user_admin_menu_id,
//          'id'     => $bp->user_admin_menu_id . '-user-capabilities',
//          'title'  => __( 'User Capabilities', 'buddyboss' ),
//          'href'   => add_query_arg( [
//              'redirect_to' => urlencode( bp_displayed_user_domain() . 'settings/capabilities/' ),
//          ], $link )
//      ) );
 
        // User Admin > Delete Account.
        $wp_admin_bar->add_menu( array(
            'parent' => $bp->user_admin_menu_id,
            'id'     => $bp->user_admin_menu_id . '-delete-user',
            'title'  => __( 'Delete Account', 'buddyboss' ),
            'href'   => add_query_arg( [
                'redirect_to' => urlencode( bp_displayed_user_domain() . 'settings/delete-account/' ),
            ], $link )
        ) );
 
    }
 
}

Changelog

Changelog
Version Description
BuddyPress 1.5.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.