Support » Plugin: Custom Profile Menu for BuddyPress » Hide tabs in other profiles

  • Resolved imparabletv

    (@imparabletv)


    Thanks for your help creating this plugin, I just noticed that the tab is also visible while viewing other people and profiles.

    How can I stop this, I want it to show on my profile alone and not while viewing my friends profile. I mean, i want every user to see this tab on their profile and no in other profiles. Because in this tabs i added information only for the user, and when they go to other peoples profiles, they can see this tab and there is their information. How i can hide the tab in other peoples profile but i want every user to see this tabs in their own profile only

    I was trying to create some code : ‘user_has_access’ => ( bp_is_my_profile() || is_super_admin() ),

    but i dont know how to finish or where to put this

    thanks

    Best regards

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Nahid Ferdous Mohit

    (@nfmohit)

    Hi there, @imparabletv !
    I hope you are doing well today!

    You can use the bp_is_my_profile() function to remove a menu item if the profile doesn’t belong to the current user.

    Here’s an example code:

    function exclude_tab_if_not_personal_profile() {
        if ( ! bp_is_my_profile() ) {
            bp_core_remove_nav_item( 'test' );
        }
    }
    add_action( 'bp_init', 'exclude_tab_if_not_personal_profile' );

    In the above code snippet, replace test with the slug of the nav item that you want to exclude.

    You can insert this code snippet in your theme’s functions.php file or as a mu-plugin.

    I hope the above helps. Please let me know if you need any further assistance regarding this. Thanks!

    Kind regards,
    Nahid

    You are amazing šŸ™‚ thanks so much man! incredible!!! is there anyway to make donations?

    Plugin Author Nahid Ferdous Mohit

    (@nfmohit)

    Hi there, @imparabletv !
    I hope you are doing well today!

    Thank you very much for getting back to me. I’m glad that the plugin and the suggested custom code snippet worked for you!

    Thank you for your interest in making a donation for my open-source cause. I currently have a Patreon page where you can become a patron.

    Also, if this plugin was useful to you, Iā€™d really appreciate if you could share your feedback regarding the plugin in the form of a review so that it can help other users seeking a similar solution.

    Kind regards,
    Nahid

    Hello,

    I tried your solution, it works, the menu are hidden
    But i tried to hide 1 menu and when i click an menu not hidden, i got an error 404.

    Could you please tell me why ?

    Thanks

    Plugin Author Nahid Ferdous Mohit

    (@nfmohit)

    Hi there, @monjolitop !
    I hope you are doing well today!

    That’s odd. I’ve tried the same on my test sites and wasn’t able to replicate the issue.

    Could you please share the code snippet that you’ve tried for this?

    I’ll be looking forward to hearing from you. Thanks!

    Kind regards,
    Nahid

    harry murtie

    (@masterseoonline)

    it should be as default feature…..!

    Plugin Author Nahid Ferdous Mohit

    (@nfmohit)

    Hi there, @masterseoonline !
    I hope you are having a great day!

    Thank you very much for your feedback. I’ve actually considered this as a default feature and am working on it. It should be available with the plugin soon! Here‘s where I have the feature request currently logged.

    Please let me know if you need any further assistance regarding this. Thanks!

    Kind regards,
    Nahid

    monjolitop

    (@monjolitop)

    Hi @nfmohit

    My code snippet is :

    
    function exclude_tab_if_not_personal_profile() {
        if (!bp_is_my_profile()) {
            bp_core_remove_nav_item('planning');
        }
    }
    add_action( 'bp_init', 'exclude_tab_if_not_personal_profile' );
    

    I have a page with ‘planning’ slug.

    Thanks,

    Plugin Author Nahid Ferdous Mohit

    (@nfmohit)

    Hey there @monjolitop !
    I hope you are doing well today!

    Thank you very much for getting back to me with the snippet of code. If the code snippet is removed, do the other pages work without errors?

    Could you try the following?

    1. Go to Settings->Permalinks and hit the “Save Changes” button.
    2. Run a plugin/theme conflict test by deactivating all other plugins and switching to a default WordPress theme to find out if the issue is caused due to another conflicting plugin.

    Hope this helps. We’ll be looking forward to hearing back from you. Thanks!

    Kind regards,
    Nahid

    monjolitop

    (@monjolitop)

    Hey,

    Yes, everything works without the code snippet.
    I did those test. I deactivated all but 3 plugins (Woocommerce, buddypress and your plugin) and I still have the issue. I tried changing the theme and it works. So it come from my theme.

    Thanks,

    Plugin Author Nahid Ferdous Mohit

    (@nfmohit)

    Hi there, @monjolitop !
    I hope you are doing well today!

    Thank you for doing the tests. I’m glad that you were able to narrow down the issue.

    You see, the bp_core_remove_nav_item is a core BuddyPress function, so there isn’t something that this plugin does to alter it. I’d humbly request you get in touch with your theme authors and request them to address the problem.

    Hope this helps. Please let me know if you need any further assistance regarding this. Thanks!

    Kind regards,
    Nahid

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.