BuddyDev

Search

[Resolved] Buddypress Only Friends Can @mention

  • Participant
    Level: Initiated
    Posts: 9
    shanki on #9639

    Hi

    I would like to limit the @mention feature to friends only. That means, only the people who are friends with you can mention you in their posts, comments etc.
    What code do I add and where?

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24712
    Brajesh Singh on #9656

    Hi Shanki,
    Welcome to BuddyDev.

    Please put this code in your bp-custom.php

    
    /**
     * Only allow suggestions for friends.
     * 
     * @param $args
     *
     * @return mixed
     */
    function buddydev_filter_suggestions_args( $args ) {
    
    	if ( ! isset( $args['group_id'] ) ) {
    		$args['only_friends'] = true;
    	}
    
    	return $args;
    }
    add_filter( 'bp_after_get_suggestions_parse_args', 'buddydev_filter_suggestions_args' );
    

    That will do it.
    Hope that helps.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved