• Resolved netreneris

    (@netreneris)


    Hello, I want to hide the profile navigation tab on a specific profile role and for that, I’m using code:

    function bpcodex_remove_member_tab_on_role() {
    	
    	$user = get_userdata( bp_displayed_user_id() );
    if ( ! in_array( 'contributor', (array) $user->roles ) ) {
    	return;
    }
    
    // not logged in user won't see these tabs
       if ( !is_user_logged_in() ) {
    	bp_core_remove_nav_item( 'contact-me' );
      }
    }
    add_action( 'bp_actions', 'bpcodex_remove_member_tab_on_role' );

    This code hide the (contact form) tab fine, but then I can’t access (I’m getting 404 error) other created forms “Post Submissions” on the specified profile “contributor”.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello, Netreneris.

    Apologies for the waiting.

    I’ll put you in contact with the dev team.
    They will get in touch ASAP.

    Thanks for your question and have a nice day.

    Plugin Contributor Jairo Niño

    (@jnfdev)

    Hi @netreneris,
    Sorry for the delay. I’m having difficult to understand the logic on your code, below I will break down of the inconsistencies I found it:

    On the first part of the code you are validating the user role of the current users, if the user doesn’t have the role “contributor” you are skipping the process. However, after this validation, you are using another validation to check if the user is logged in, only when the user is not logged you’re removing the navigation tab, what doesn’t make sense because not logged-in users doesn’t have roles.

    Maybe you can bring more details on what you are traying to do, that would be handy for us.

    I will be waiting for your reply.

    Thread Starter netreneris

    (@netreneris)

    Hello Jairo,

    thanks for your reply. I do not know the coding and that code I found on the forums. 🙂 On my website is two membership level – silver (wp-contributor) & gold (wo-author role). Website visitors can contact via email to the members who have a Gold membership, and can’t connect with a member who has Silver membership. Members with Silver and Gold membership can post articles and these articles are shown on their profile’s tab (I’m using buddyboss theme&plugin). With the code below I achieved that only member with contributor role, doesn’t have “Contact-me” tab on their profile but then I get an 404 error when visiting articles tabs. You can check by yourself.

    Gold member https://www.epsychology.app/therapists/ugne-juodyte/

    Silver member https://www.epsychology.app/therapists/birute-flemming/

    Thread Starter netreneris

    (@netreneris)

    Hello @jnfdev, do you have any ideas how to fix that?

    Plugin Contributor Jairo Niño

    (@jnfdev)

    Hello @netreneris,
    I did a test and I can confirm that once I use the function bp_core_remove_nav_item I start getting 404 on all the BuddyForms integrate tabs, In order to give you a good answer, I will need to do a more deeply research. I will deep dive and once I have any update I will back you.

    Thank you for your patient, have a nice day.

    Plugin Contributor Jairo Niño

    (@jnfdev)

    Hi @netreneris,

    I have an alternative solution that you definitely should try. If you are using a contact form you can manage the visibility by restricting the creation permission from the Form Builder, see this image: https://prnt.sc/13xtnrf

    As you can see in the image you can check or uncheck permissions per user role, so what you have to do is just checking the user role you wanna see the form (checking the create checkbox) and let other ones as uncheck.

    Let me know if you got the point or if you have any question left. Have a nice day.

    • This reply was modified 2 years, 10 months ago by Jairo Niño.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘hide profile tabs’ is closed to new replies.