Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)

  • jack5253
    Participant

    @jack5253

    Pittythings is a dynamic platform offering diverse content on lifestyle, fashion, beauty, travel, entertainment, and technology. With informative articles and engaging topics, it caters to a broad audience seeking insights and inspiration across various aspects of daily life and interests.


    jack5253
    Participant

    @jack5253

    To achieve this functionality, you can redefine the bp_setup_nav function by hooking into the bp_actions action. Inside your custom function, you can check if the user is on their own profile page (bp_is_my_profile()) and if a specific main menu item is active. Based on these conditions, you can add the desired submenu items with the default subnav slug.

    Here’s an example of how you can implement this:

    `php
    function custom_bp_setup_nav() {
    if ( bp_is_my_profile() ) {
    // Check if ‘settings’ main menu item is active
    if ( bp_is_current_component( ‘settings’ ) ) {
    bp_core_new_subnav_item( array(
    ‘name’ => __( ‘My Email’, ‘text-domain’ ),
    ‘slug’ => ‘my-email’,
    ‘default_subnav_slug’ => ‘my-email’,
    ‘parent_url’ => bp_loggedin_user_domain() . ‘settings/’,
    ‘parent_slug’ => ‘settings’,
    ‘screen_function’ => ‘bp_settings_screen_my_email’,
    ‘position’ => 30,
    ‘user_has_access’ => bp_is_my_profile()
    ) );
    }

    // Check if ‘xprofile’ main menu item is active
    if ( bp_is_current_component( ‘xprofile’ ) ) {
    bp_core_new_subnav_item( array(
    ‘name’ => __( ‘Change Avatar’, ‘text-domain’ ),
    ‘slug’ => ‘change-avatar’,
    ‘default_subnav_slug’ => ‘change-avatar’,
    ‘parent_url’ => bp_loggedin_user_domain() . ‘profile/’,
    ‘parent_slug’ => ‘profile’,
    ‘screen_function’ => ‘bp_xprofile_screen_change_avatar’,
    ‘position’ => 30,
    ‘user_has_access’ => bp_is_my_profile()
    ) );
    }
    }
    }
    add_action( ‘bp_actions’, ‘custom_bp_setup_nav’, 999 );
    `

    In this code:

    – We define the custom_bp_setup_nav function to check if the user is on their own profile page using bp_is_my_profile().
    – We then check if the ‘settings’ or ‘xprofile’ main menu items are active using bp_is_current_component().
    – Based on these conditions, we add the desired submenu items with the default subnav slug using bp_core_new_subnav_item().

    Make sure to replace 'settings', 'xprofile', 'my-email', and 'change-avatar' with the actual slugs of your main menu items and submenu items. Additionally, adjust the screen_function and other parameters as needed to match your implementation.

Viewing 2 replies - 1 through 2 (of 2 total)
Skip to toolbar