Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] How can I disable secondary avatars in activity items?


  • jreeve
    Participant

    @jreeve

    I know I can disable them in css, with .activity-header > p > a > img.avatar { display: none; }, but I’d like to disable them in PHP, so that the page might load a little faster.

    I figure I have to remove the filter secondary_avatars from the hook bp_get_activity_action_pre_meta, but since it was added with an object context, I have to do that with an array containing the variable instance of the BP_Legacy object. It would look something like this: remove_filter( 'bp_get_activity_action_pre_meta', array( $bp_legacy_var???, 'secondary_avatars', 10 ) );, but I don’t know what $bp_legacy_var??? is supposed to be. Does anyone know?

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

  • shanebp
    Moderator

    @shanebp

    You’re talking about the value of $this in the filter call in class BP_Legacy extends BP_Theme_Compat ?
    add_filter( 'bp_get_activity_action_pre_meta', array( $this, 'secondary_avatars' ), 10, 2 );

    Good question.
    And I’d be interested in the answer.

    There must be a simple way to disable secondary avatars…
    You might want to ask about this on Slack.

    Meanwhile, this works, not very efficient ‘tho.
    Hook is in bp-activity\bp-activity-template.php

    function remove_secondary_avatar( $item_id ){
    	
    	$item_id = '';
    	
    	return $item_id;
    }
    add_filter( 'bp_get_activity_secondary_avatar_item_id', 'remove_secondary_avatar' );

    And this works, but I don’t know why :<

    function remove_activity_secondary_avatars( $action, $activity ) {
        
        if ( $activity->component = NULL ) {
    	// don't do anything
        }
    
        return $action;
    }
    add_filter( 'bp_get_activity_action_pre_meta', 'remove_activity_secondary_avatars', 10, 2 );

    r-a-y
    Keymaster

    @r-a-y

    This should work:

    function my_remove_secondary_avatars( $bp_legacy ) {
        remove_filter( 'bp_get_activity_action_pre_meta', array( $bp_legacy, 'secondary_avatars' ), 10, 2 );
    }
    add_action( 'bp_theme_compat_actions', 'my_remove_secondary_avatars' );

    Untested, but let me know if it works!


    shanebp
    Moderator

    @shanebp

    Works for me. Thanks @r-a-y.


    jreeve
    Participant

    @jreeve

    Thanks @r-a-y, that works like a charm.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] How can I disable secondary avatars in activity items?’ is closed to new replies.
Skip to toolbar