BuddyDev

Search

Remove last active, span.activity from own profile

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #48462

    Hi there, I’m looking for a solution for excluding last active span.activity from own profile, because it makes no sense having it there.

    Can you help me with a code snippet which removes span.activity on my.profile?

    Regards
    Carsten

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #48463

    I hided it with css instead, thank you.

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #48464

    The span.activity don’t fit into div.item-meta in my design.

    I would like to move span.activity up under entry-title using this hook
    generate_after_page_title

    Can you help me with this code?

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24096
    Brajesh Singh on #48484

    Hi Carsten,
    Thank you for the question.

    Are you using BP Legacy or BP Nouveau template pack?

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #48490

    Hi Brajesh

    Thanks for helping out, I’m using Nouveau template.

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24096
    Brajesh Singh on #48509

    Hi Carsten,
    You can use the following code to remove the last activity meta from profile.

    
    // remove last activity.
    add_filter( 'bp_nouveau_get_member_meta', function ( $meta, $member, $is_loop ) {
    
    	if ( $is_loop ) {
    		return $meta;
    	}
    	unset  ( $meta['last_activity'] );
    
    	return $meta;
    }, 10, 3 );
    
    

    After that, you can print the meta anywhere you need. Since you mentione dthe hook ‘generate_after_page_title’, is that an action of filter hook?

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #48513

    Hi Brajesh, thanks, ‘generate_after_page_title’ appears to be an action hook

    https://imgur.com/R9JhXne

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24096
    Brajesh Singh on #48527

    Hi Carsten,
    Thank you.

    Please add the following too

    
    
    add_action( 'generate_after_page_title', function () {
    	if ( ! bp_is_user() ) {
    		return;
    	}
    
    	printf(
    		'<span class="activity">%s</span>',
    		esc_html( bp_get_last_activity( bp_displayed_user_id() ) )
    	);
    
    } );
    

    That should generate the content after title.

    Regards
    Brajesh

  • Participant
    Level: Yogi
    Posts: 1105
    calu on #48547

    Hi Brajesh, thank you very much for your help with this code snippet, which makes the profile design possibilities much better.

    But I have an issue with styling, I’m trying to add a div class for styling like this, but it breaks my site, no matter how I wrap it?

    <div class=”activity”>
    </div>

    Regards
    Carsten

  • Keymaster
    (BuddyDev Team)
    Posts: 24096
    Brajesh Singh on #48583

    Hi Carsten,

    please avoid using class ‘activity’ on div. BuddyPress will treat it as activity list container and will apply some undesired css.

    You should change the class if you want to use div.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved