How to search messages by username?


Home Forums Front End PM PRO How to search messages by username?

This topic is: Resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #41758
    Hlaing Min
    Participant

    Hi, I noticed that usernames of the users the account holder is communicating with are displayed on the messages.

    I typed in a “username” in the “Search Messages”, but it didn’t work. If there are a lot of messages and users, it will be very difficult to hard to manage messages if there is no search system by usernames. How can I make sure that messages of that “username” searched by typing in the “Search Messages” appear?

    Thank you very much in advance.

    #41770
    shamim
    Keymaster
    #41800
    Hlaing Min
    Participant
    This reply has been marked as private.
    #41820
    shamim
    Keymaster

    Please try following code

    add_filter( 'fep_message_query_args', function( $args, $user_id ) {
    	if( ! empty( $args['s'] ) && ( $user = get_user_by( 'login', trim( $args['s'] ) ) ) ) {
    		$args['participant_query'][] = array(
    			'mgs_participant' => $user->ID,
    		);
    		unset( $args['s'] );
    	}
    	return $args;
    }, 10, 2 );
    
    #41829
    Hlaing Min
    Participant

    Thank you. it works.

Viewing 5 posts - 1 through 5 (of 5 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.