BuddyDev

Search

[Resolved] Reposition custom profile action button

  • Participant
    Level: Initiated
    Posts: 11
    Omar on #38946

    Hello,

    so I follow this tutorial https://buddydev.com/support/forums/topic/how-to-add-custom-buttons-to-buddypress-profile-page/ to add a custom button, it’s working but the button gets added to the far right or last option, I’d like to reposition the button to the far left or first option. How can achieve this? TY!

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #38954

    Hi Omar,
    Thank you for the question.

    You can change the priority.
    For example, instead of this line

    
    add_filter( 'bp_nouveau_get_members_buttons', 'buddydev_add_custom_buttons' );
    
    

    you can use this

    
    add_filter( 'bp_nouveau_get_members_buttons', 'buddydev_add_custom_buttons', 0 );
    
    

    Please give it a try.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    Omar on #38964

    Hi, thank you very much for your response.

    I actually was using ‘bp_member_header_actions’, instead of ‘bp_nouveau_get_members_buttons’, when I use ‘bp_nouveau_get_members_buttons’ it only shows the new custom button.

  • Participant
    Level: Initiated
    Posts: 11
    Omar on #38965

    When I use ‘add_filter( ‘bp_member_header_actions’, ‘add_custom_button’, 0);’ nothing changes

  • Participant
    Level: Initiated
    Posts: 11
    Omar on #38966

    The custom button stays in the same position

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #38967

    Hi Omar,
    which theme and template pack are you using? Also, are you using anything like Youzer?

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    Omar on #38969

    I’m using BuddyBoss Child theme to add the custom functions. I have Elementor installed. Not using Youzer

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #38985

    Hi Omar,
    I am sorry, The code will not work with BuddyBoss. It does not matter at what priority you attach it as they first generate markup for their enabled buttons and then append then buttons hooked at ‘bp_member_header_actions’.

    Please get in touch with BuddyBoss support and see if they can help. You might need a different hook.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    Omar on #38986

    Thank you very much for your help Brajesh. I’ll contact them.

    Just one more thing that I’d like to know if you could help, I’d like to add a condition to that button based on the role of the displayed user. If it’s X role show the button. Thanks a million again!

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #38994

    Hi Omar,
    sure.

    You can use something on this line in the code where you are generating button

    
    $user = get_user_by( 'id', bp_displayed_user_id() );
    
    if ( in_array( 'subscriber', $user->roles ) ) {
    	// some button
    } elseif ( in_array( 'contributor', $user->roles ) ) {
    	//some other button ...
    }
    // and so on..
    
    

    Hope you can adapt it.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved