BP_XProfile_Component::setup_nav( array $main_nav = array(), array $sub_nav = array() )

Set up navigation.

Description

Parameters

$main_nav

(Optional) Array of main nav items to set up.

Default value: array()

$sub_nav

(Optional) Array of sub nav items to set up.

Default value: array()

Source

File: bp-xprofile/classes/class-bp-xprofile-component.php

237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
 
    // Determine user to use.
    if ( bp_displayed_user_domain() ) {
        $user_domain = bp_displayed_user_domain();
    } elseif ( bp_loggedin_user_domain() ) {
        $user_domain = bp_loggedin_user_domain();
    } else {
        return;
    }
 
    $access       = bp_core_can_edit_settings();
    $slug         = bp_get_profile_slug();
    $profile_link = trailingslashit( $user_domain . $slug );
 
    // Add 'Profile' to the main navigation.
    $main_nav = array(
        'name'                => __( 'Profile', 'buddyboss' ),
        'slug'                => $slug,
        'position'            => 20,
        'screen_function'     => 'xprofile_screen_display_profile',
        'default_subnav_slug' => 'public',
        'item_css_id'         => $this->id
    );
 
    // Add the subnav items to the profile.
    $sub_nav[] = array(
        'name'            => __( 'View', 'buddyboss' ),
        'slug'            => 'public',
        'parent_url'      => $profile_link,
        'parent_slug'     => $slug,
        'screen_function' => 'xprofile_screen_display_profile',
        'position'        => 10
    );
 
    // Edit Profile.
    $sub_nav[] = array(
        'name'            => __( 'Edit', 'buddyboss' ),
        'slug'            => 'edit',
        'parent_url'      => $profile_link,
        'parent_slug'     => $slug,
        'screen_function' => 'xprofile_screen_edit_profile',
        'position'        => 20,
        'user_has_access' => $access
    );
 
    // Change Avatar.
    if ( buddypress()->avatar->show_avatars ) {
        $sub_nav[] = array(
            'name'            => __( 'Profile Photo', 'buddyboss' ),
            'slug'            => 'change-avatar',
            'parent_url'      => $profile_link,
            'parent_slug'     => $slug,
            'screen_function' => 'xprofile_screen_change_avatar',
            'position'        => 30,
            'user_has_access' => $access
        );
    }
 
    // Change cover photo.
    if ( bp_displayed_user_use_cover_image_header() ) {
        $sub_nav[] = array(
            'name'            => __( 'Cover Photo', 'buddyboss' ),
            'slug'            => 'change-cover-image',
            'parent_url'      => $profile_link,
            'parent_slug'     => $slug,
            'screen_function' => 'xprofile_screen_change_cover_image',
            'position'        => 40,
            'user_has_access' => $access
        );
    }
 
    // The Settings > Profile nav item can only be set up after
    // the Settings component has run its own nav routine.
    add_action( 'bp_settings_setup_nav', array( $this, 'setup_settings_nav' ) );
 
    parent::setup_nav( $main_nav, $sub_nav );
}

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.