This topic has 7 replies, 3 voices, and was last updated 9 years by Andrei.

  • Author
  • #54216
     thannah
    Participant

    Looking for a way to display Bp tabs to certain members. For example

    ‘TAB1’ and ‘TAB2 needs to only show up to Pmpro Level ID 2 & 3

    ‘TAB3’ and ‘TAB4’ needs to only show up to PmPro Level ID 4 & 5

    Is there a custom code or something I can add to make this happen?

    #54651
     Andrei
    Moderator

    Hi, this is doable but unfortunately is a pretty custom request and if you don’t have the proper knowledge to do them by yourself then you’ll probably need to hire an developer to build this feature.

    Let me know if I can help you with anything else.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #54684
     thannah
    Participant

    Thank you. I can probably figure it out. I’ve learned alot about php since I started this project. What files would I work with to make these changes?

    #55177
     Andrei
    Moderator

    Hi,

    I’ve spent some time on this so hope it will work as you expect:

    COPY CODE
    
    function hide_profile_tabs_by_pmpro_level(){
        if(function_exists('pmpro_hasMembershipLevel')){
            global $bp_tabs, $current_user;
            $user_level = (int)$current_user->membership_level->ID;
            $allowed_tabs_per_level = array(
                '0' => array(),
                '1' => array('Base'),
                '2' => array('Base', 'Lifestyle'),
            );
            if($bp_tabs){
                foreach($bp_tabs as $bp_tab_id => $bp_tab){
                    if(!in_array($bp_tab['name'], $allowed_tabs_per_level[$user_level])){
                        unset($bp_tabs[$bp_tab_id]);
                    }
                }
            }
        }
    }
    add_action('bp_after_member_header', 'hide_profile_tabs_by_pmpro_level', 1);
    

    You just have to populate the $allowed_tabs_per_level array with your levels > tab names.
    Let me know how it went.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #55263
     thannah
    Participant

    You are an ANGEL! This worked like a pro and I have been banging my head up against the wall. Thank you so much! I’m a graphic designer so if there is anything I can help you with please let me know!

    #55276
     Andrei
    Moderator

    I’m glad it helped you, would be nice if you could leave a review and a rate on themeforest when and if you have time.
    Thanks

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #70070
     erikland
    Participant

    Hi Andrei!

    I want to do the same in my theme, can you please tell me where this code needs to be placed?

    Kind regards,

    Erik

    #75298
     Andrei
    Moderator

    In the functions.php file from your active theme.
    Cheers

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?