Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do I change the activity-greeting copy?


  • allancaeg
    Participant

    @allancaeg

    I want to ask users to post something very specific.

    How do I change the activity-greeting text from “What’s new, [username]?”

    to “What’s new about [your goal], [username]?

    Where [your goal] swaps with a user profile field. If that’s too hard, I can just stick with “What’s new with your goal, [username]?”

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

  • socialc
    Participant

    @socialc

    Inside your theme, make sure there is a file wp-content/themes/your-theme/buddypress/activity/post-form.php. If there is no file in that location copy this file wp-content/plugins/buddypress/bp-templates/bp-legacy/buddypress/activity/post-form.php into the first location.

    Then, look at line number 28 – 32 of post-form.php.

    From there, you will notice you can change this text for the activity update form which reads “What’s new in “GROUP NAME” if you’re on a group page posting the update or “What’s new USERNAME” if you’re any where else.

    So, to swap in a specific profile field you’d need to supply a bit more about the nature of your project and how it’s setup. You could simply drop in some static text, but if you want it to relate to a specific profile field in a dynamic way then please elaborate further.


    danbp
    Participant

    @danbp

    Hi,

    Try somthing like this to fetch the field.

    
    function allan_goal(  $user_id = 0, $field_name = 'Your goal' ) {
    
    	$return = false;
    	
    	if ( empty( $user_id ) || empty( $field_name ) || ! bp_is_active( 'xprofile' ) ) {
    		return $return;
    	}	
    	// assuming field is called Your goal
    	$goal = xprofile_get_field_data( 'Your goal', $user_id );
    
       return $return;
    }

    To output field value, something like:
    What’s new with <?php allan_goal() ?>, [username]?


    socialc
    Participant

    @socialc

    @danbp shouldn’t you be returning $goal here?


    danbp
    Participant

    @danbp

    @social yes and no.
    Yes if you consider the example function without having ‘if’ conditionnals.
    If ‘conditionnals’ is empty, return = false. If not, return true.

    No if you add What’s new with bla bla…, to function, in which case you can do
    return 'What's new about '. $goal .' ';

    If + return are not empty, so you return $return.


    socialc
    Participant

    @socialc

    The function will never return false as you’ve set a default for $goal in the parameters.

    If it were to be defaulting to null and no $user_id was set the return would be false.

    When a value is passed to the $goal parameter and assuming the label was in the DB the return would still be false.

    Maybe I’m reading this wrong.


    danbp
    Participant

    @danbp

    Maybe it’s me who’s wrong. I haven’t tested, but it’s how i used such a function in the past, called inside another one. I also wrote “something like”, which is very different of “use this”. It’s an example, not the absolute solution! 😉

    Let’s wait for Allan’s reaction before continuing this discussion. For the moment, the only important thing related to this post is:

    $goal = xprofile_get_field_data( 'Your goal', $user_id );

    Function reference.


    socialc
    Participant

    @socialc

    @danbp yeah, sorry about that :). Reason I went a bit further was when working on a theme earlier I was using a function get_displayed_group_id() or something with a similar name. I was expecting a return value but it was echoing no matter where I placed this.

    Ended up using a different method.

    Just wondered if there were other functions inside BuddyPress that looked like a return value but had output instead.


    danbp
    Participant

    @danbp

    BP files are very well commented actually. But reading through hundreds of files is not easy. Here a good ressource to find a function, hook by keywords. Still interesting even if related to BP 2.4.3
    Test and search for get_ to have an idea !


    socialc
    Participant

    @socialc

    Nice one, cheers.

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