Hello,
I hope you can help me with this. I want to change the buttons at the profile header on the user profile.
I have 4 buttons there, one for friendship, one for public and private message and one to block a user.
This is the html code for the first button:<button id="friend-26" class="friendship-button not_friends add" rel="add" title="Add friend" data-bp-nonce="http://localhost/members/jon/friends/add-friend/26/?_wpnonce=2228b5ba33" data-bp-btn-action="not_friends">Add friend</button>
I just want to add a span tag for each of the buttons like this:
<button id="friend-26" class="friendship-button not_friends add" rel="add" title="Add friend" data-bp-nonce="http://localhost/members/jon/friends/add-friend/26/?_wpnonce=2228b5ba33" data-bp-btn-action="not_friends"><span>Add friend</span></button>
So for the button message ,”send message” should become to “<span>send message</span>” and so on.
Where can I make these code changes? I searched buddypress but can’t find a doc how to do this. I just found your article how to add two more buttons.
Make the changes at bp_nouveau_member_header_buttonsI found the 4 files where I can make my changes. It is bp-friends-template, bp-activity-template, bp-messages-template and class-bp-toolkit-block.
Regarding the first 3 templates. Will they be overwritten on next buddypress update? And how can I protect them?
Copying those files to the child theme does not work regarding to this post: https://buddypress.org/support/topic/copy-buddypress-files-into-child-theme/.Hi Josh,
Hope you are doing well.I am sorry for the delayed reply.
Event though it looks simple, There is no straight way. There are 2 ways to achieve it and I will explain both. Also, changing it will impact all the other places this button is being used.
1. The simple strategy would be to use a localization plugin and change the text to text with the span markup. It will work.
2. Or you can filter on ‘bp_get_add_friend_button’ and other similar filters to update the text. I will not recommend it as you will need to do it for all the buttons and it may not be worth the effort.
Regards
BrajeshFor the last 3 buttons I made it work with using the translating file to add the tag. But for the first button it is difficult cause this button also uses the same translation for presenting the title tooltip. So if someone hovers over the button he sees <span class=….</span> which is not good.
I tried to solve this via jquery to prevent the buttom from showing the title but cant make it work. If buddypress wouldn’t use the same text for this button on the button and the title it would be much easier.
So I have to stay with overwriting the core bp-friends-template file for now :-((
In case you have a solution for the first button I would be happy to hear it!
Hi Josh,
Thank you for the reply.
There are solutions like unhooking the button and hooking your own custom one. The problem is BuddyPress/BuddyBoss has a convoluted implementation for these basic things. The time invested in fixing/changing feel so much unrewarding.If it is highly necessary, I will suggest you look into how these buttons are generated and hooked into the header.
Regards
Brajesh
You must be logged in to reply to this topic.