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
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
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.