How to search messages by username?


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

This topic is: Resolved
Viewing 7 posts - 1 through 7 (of 7 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 Hasan
    Keymaster
    #41800
    Hlaing Min
    Participant
    This reply has been marked as private.
    #41820
    Shamim Hasan
    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.

    #43661
    hauke.winkler
    Participant

    This works good for me, thanks for the code, shamim! I have one small addition: Is it somehow possible to implement a partial search? E.G. I want to search for the messages of the user “computerdude42” and I type in the searchfield “dude42” or “computerdude”. At the moment the username has to be precise for the search to work.

    Have a nice weekend! 🙂
    Hauke

    #43680
    Shamim Hasan
    Keymaster

    It will be possible but require many code. If you need that badly you can contact me using https://www.shamimsplugins.com/hire/

Viewing 7 posts - 1 through 7 (of 7 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.