Home › Forums › Front End PM PRO › How to search messages by username?
Tagged: search username
- This topic has 6 replies, 3 voices, and was last updated 4 years, 2 months ago by Shamim Hasan.
- AuthorPosts
- November 15, 2020 at 11:06 pm #41758Hlaing MinParticipant
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.
November 16, 2020 at 5:39 pm #41770Shamim HasanKeymasterNovember 18, 2020 at 8:28 pm #41800Hlaing MinParticipantThis reply has been marked as private.November 19, 2020 at 1:37 pm #41820Shamim HasanKeymasterPlease 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 );November 19, 2020 at 9:21 pm #41829Hlaing MinParticipantThank you. it works.
September 17, 2021 at 5:59 pm #43661hauke.winklerParticipantThis 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! 🙂
HaukeSeptember 21, 2021 at 10:31 am #43680Shamim HasanKeymasterIt will be possible but require many code. If you need that badly you can contact me using https://sp-test1.arogga.co/hire/
- AuthorPosts
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.