Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/10/2012 06:47:31 PM (14 years ago)
Author:
johnjamesjacoby
Message:

Toggle displayed/logged-in user for sub-nav. Bail if no menu should be available. Add 'user_has_access' checks where applicable. Reverts r6519. Fixes #4661.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-loader.php

    r6585 r6622  
    160160        );
    161161
    162         $profile_link = trailingslashit( bp_loggedin_user_domain() . $this->slug );
     162        // Determine user to use
     163        if ( bp_displayed_user_domain() ) {
     164            $user_domain = bp_displayed_user_domain();
     165        } elseif ( bp_loggedin_user_domain() ) {
     166            $user_domain = bp_loggedin_user_domain();
     167        } else {
     168            return;
     169        }
     170
     171        $profile_link = trailingslashit( $user_domain . $this->slug );
    163172
    164173        // Add the subnav items to the profile
     
    172181        );
    173182
    174         if ( bp_is_my_profile() ) {
    175             // Edit Profile
    176             $sub_nav[] = array(
    177                 'name'            => __( 'Edit', 'buddypress' ),
    178                 'slug'            => 'edit',
    179                 'parent_url'      => $profile_link,
    180                 'parent_slug'     => $this->slug,
    181                 'screen_function' => 'xprofile_screen_edit_profile',
    182                 'position'        => 20
    183             );
    184 
    185             // Change Avatar
    186             $sub_nav[] = array(
    187                 'name'            => __( 'Change Avatar', 'buddypress' ),
    188                 'slug'            => 'change-avatar',
    189                 'parent_url'      => $profile_link,
    190                 'parent_slug'     => $this->slug,
    191                 'screen_function' => 'xprofile_screen_change_avatar',
    192                 'position'        => 30
    193             );
    194         }
     183        // Edit Profile
     184        $sub_nav[] = array(
     185            'name'            => __( 'Edit', 'buddypress' ),
     186            'slug'            => 'edit',
     187            'parent_url'      => $profile_link,
     188            'parent_slug'     => $this->slug,
     189            'screen_function' => 'xprofile_screen_edit_profile',
     190            'position'        => 20,
     191            'user_has_access' => bp_core_can_edit_settings()
     192        );
     193
     194        // Change Avatar
     195        $sub_nav[] = array(
     196            'name'            => __( 'Change Avatar', 'buddypress' ),
     197            'slug'            => 'change-avatar',
     198            'parent_url'      => $profile_link,
     199            'parent_slug'     => $this->slug,
     200            'screen_function' => 'xprofile_screen_change_avatar',
     201            'position'        => 30,
     202            'user_has_access' => bp_core_can_edit_settings()
     203        );
    195204
    196205        parent::setup_nav( $main_nav, $sub_nav );
Note: See TracChangeset for help on using the changeset viewer.