Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • honoluluman
    Participant

    @honoluluman

    Hello @shanebp , needed to inform you that i get an error with WordPress debug about the code above.

    Trying to get property 'roles' of non-object in line $displayed_user_roles = $displayed_user->roles; i dont know why.


    honoluluman
    Participant

    @honoluluman

    @msteimann if you still need this just tell me i can help you.


    honoluluman
    Participant

    @honoluluman

    So i managed to solve this problem with some CSS, unfortunately there is no possibility to wrap with any html element around (%s) , BUT there is possibility to wrap with html the rest. So i did this

    printf( '<span id="keep"><span id="%s" href="#"></span><img src="%s" style="width: 15px"> &nbsp; %s</span> (%s)' . "\n",

    with out removing nothing from the original code, just adding the span ‘keep’ and then with the classic css visibility:hidden; trick i managed to hide it simple.


    honoluluman
    Participant

    @honoluluman

    @clickallco thanks for the reply. Unfortunatelly in legacy it is like that `<li class=”ac_event ac_over”><span id=”link-username” href=”#”></span>
    <img src=”https://www.test.com/wp-content/uploads/avatars/23/user-bpthumb.jpg&#8221; style=”width: 15px”>   User (<strong>U</strong>sername)</li>`

    and there is no element to hide the (<strong>U</strong>sername)


    honoluluman
    Participant

    @honoluluman

    Hello, did you manage to find solution to this issue?


    honoluluman
    Participant

    @honoluluman

    Hello, did you manage to find solution to this issue?


    honoluluman
    Participant

    @honoluluman

    So i managed to find the appropriate code in case someone also needs it:

    define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true );
    
    /**
     * Filter and remove subscribers and user's own mail from all BuddyPress auto complete box.
     *
     * @param array $args BP_User_Query args.
     *
     * @return array
     */
    function buddydev_filter_buddypress_auto_complete_ids( $args ) {
    	$user_ids = isset( $args['exclude'] ) ? $args['exclude'] : array();
    
    	if ( $user_ids && ! is_array( $user_ids ) ) {
    		$user_ids = wp_parse_id_list( $user_ids );
    	}
    
    	$excluded = get_users( array( 'role' => 'subscriber', 'fields' => 'ID' ) );
    
    	if ( is_user_logged_in() ) {
    		array_push( $excluded, get_current_user_id() );
    	}
    
    	$args['exclude'] = array_merge( $excluded, $user_ids );
    	return $args;
    }
    add_filter( 'bp_members_suggestions_query_args', 'buddydev_filter_buddypress_auto_complete_ids' );

    with this i can have excluded from autocomplete all subscribes by hooking to bp_members_suggestions_query_args


    honoluluman
    Participant

    @honoluluman

    hello @andrewteg, i am trying to do the same. Did you figure it out?


    honoluluman
    Participant

    @honoluluman

    I was also thinking that i could skip the use of define( 'BP_MESSAGES_AUTOCOMPLETE_ALL', true ); and since i just want to have in the autocomplete contributors+admins

    it could be a function that makes all of those users friends with out the need of bp friends component?


    honoluluman
    Participant

    @honoluluman

    Or maybe the opposite, just dont allow Subscribers in the result.


    honoluluman
    Participant

    @honoluluman

    Yes @shanebp, this works perfect. Thank you again for your help


    honoluluman
    Participant

    @honoluluman

    Hello @shanebp,

    Thank you so much for your help 🙂
    I have tried your code (and also changed you last return button; with return $button; ), but it doesn’t work.

    If i login as subscriber all msg buttons are removed from all users profiles, which is correct.
    If i login as contributor i can see msg buttons on contributors and admins profiles , but also on subscribers profiles, which i would like not to.

    *Lets assume that contributors and admins have ID 23, 6, 25 .
    I tried many variations with your code but no luck.

Viewing 12 replies - 1 through 12 (of 12 total)
Skip to toolbar