Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Recognise logged on user in activity


  • Paul Bursnall
    Participant

    @style960

    Substitute the username for ‘You’ on activity updates, comments made by the logged-on user. Reading my own activity when logged-on is like reading from third person perspective.

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

  • NicolaCirotto
    Participant

    @nicolacirotto

    I have a little gift for you.
    Add this code in your functions.php

    function my_test($args)
    {
    	if( is_user_logged_in() )
    	{
    		global $activities_template;
    		$logged_user = bp_core_get_user_displayname( bp_loggedin_user_id() );
    		if (strpos($args, $logged_user) !== false)
    		{
    			$old_text = '>' . $logged_user . '</a>';
    			$new_text = '>' . __('You', 'buddypress') . '</a>';
    			$args = str_replace($old_text, $new_text, $args);
    		}
    	}
    	return $args;
    }
    add_filter('bp_get_activity_action', 'my_test');

    Paul Bursnall
    Participant

    @style960

    @nicolacirotto Thanks! Always good to share 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Recognise logged on user in activity’ is closed to new replies.
Skip to toolbar