Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity tab title text change


  • Ariful Alam Tuhin
    Participant

    @arifulalamtuhin

    Hello,
    In BuddyPress activity page, there are some tabs like “All Friends”, “Groups”, “Favorites”, “Mentions” etc. I would like to change those text to others, like without “Favorites” I like to show “Likes” or “Loves”.

    Now, one way is to copy BuddyPress themes activity directory to WP Theme directory and modify there directly. But is there anyway to create an action/hook in theme’s functions.php and change those text without copying + editing BP theme activity layouts.

    NOTE: using updated WP and BP.

    Regards

Viewing 8 replies - 1 through 8 (of 8 total)

  • danbp
    Moderator

    @danbp

    Hi,
    this can be done via a child-theme or with a function to add to bp-custom.php or child’s functions.php
    See examples here: https://codex.buddypress.org/developer/navigation-api/


    Ariful Alam Tuhin
    Participant

    @arifulalamtuhin

    Hello @danbp,
    Thanks for your reply. The link you shared, work for individual user’s profile page. But I don’t required that. I am asking for activity page. Where there is a status update text area and bottom of that links for All Members, Favorites, Mentions etc. I like to change text/label for these “All Members”, “favorites”, “Mentions” etc.

    Regards


    danbp
    Moderator

    @danbp

    @arifulalamtuhin,

    you can do that via the language file or alter the text of those items directly in the activity template, via a child-theme.
    Concerned file is in bp-templates/bp-legacy/buddypress/activity/index.php:72,91,108


    Ariful Alam Tuhin
    Participant

    @arifulalamtuhin

    @danbp,
    Thanks for your quick reply. I can do that. By coping activity directory to WP Theme directory. But the WP theme used breaking page layout. And if fix page layout for activity page, that breaking other page layout. And not have permission to modify WP theme currently. That’s why asking if there any action hook available. 🙂

    Thanks again for your help 🙂

    Regards


    danbp
    Moderator

    @danbp

    Annoying to work on a site where you’re not allowed to access the child-theme!
    As you can see in index.php, there is no action hook for these buttons.

    The only other way i know is a dirty trick using directly gettext.
    Add this to bp-custom.php

    
    function abcd_gettext( $translated, $original_text, $domain ) {
    
        if ( 'buddypress' !== $domain )  
               return $translated;
    
        switch ( $original_text ) {
            case 'All Members %s':
                return 'All Buddies %s';
    
    		case 'My Friends %s':
                return 'My Amigos %s';
    
            default:
                return $translated;
        }
    }
    add_filter( 'gettext', 'abcd_gettext', 10, 3 );

    More about that trick here:
    https://buddypress.org/support/topic/how-do-i-change-the-title-of-the-create-an-account-page/#post-254772


    Ariful Alam Tuhin
    Participant

    @arifulalamtuhin

    Hello @danbp,
    Thanks for your dirty way trick. That works and not too. Like, I added a case

    case 'My Favorites %s':
    return 'Likes %s';

    After that when I load/refresh the activity page, that changes “My Favorites” to “Likes”. Awesome!
    But whenever, I unlike all liked activity, and then again like a activity, instead of “Likes”, that showing “My Favorites”

    Regards


    danbp
    Moderator

    @danbp

    Yep, you’re right, the forced translation comes only if you reload the page.

    That’s the dark side of a dirt trick. 😉

    Now, in a very real use case, this wouldn’t happen very often for not saying never. Most users will (hopefully for you) favorite activities, but i don’t believe that many will favorite and suddenly decide to unfavorite all their stuff and will restart immediatly to fav…

    If you don’t agree with this, you still have the possibility to change text in the template or to use the po/mo file.

    In witch language is your site ?


    Ariful Alam Tuhin
    Participant

    @arifulalamtuhin

    site is in english. 🙂
    Not to worry for now as authority decided not to show that section in activity page.

    Thanks for all your effort 🙂

    Regards

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