Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+7 votes
1.3k views
in Q2A Core by
Hi There,

As an admin, how I can search for a user by their email or username?

Thanks
Q2A version: 1.7.4
by
It would have been a nice feature but, Q2A doesn't have this feature as off now.

1 Answer

+1 vote
by
by
Thank you. This plugin searches for usernames. Do you know how we can search for users by email? thanks
by
Edit page q2apro-ajax-usersearch-page.php

change line 57

from this

WHERE `handlel` LIKE #

to this

WHERE `email` LIKE #
by
edited by
You probably don't want users being able to search email addresses so change this:
               
                // ajax return all user events
                $potentials = qa_db_read_all_assoc(
                    qa_db_query_sub(
                        'SELECT userid FROM ^users
                         WHERE `handle` LIKE #
                         LIMIT #',
                        '%'.$username.'%',
                        qa_opt('q2apro_ajax_usersearch_maxshow')                       
                    )
                );
               
to this

                // ajax return all user events
                if ( qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN ) {
                $potentials = qa_db_read_all_assoc(
                    qa_db_query_sub(
                        'SELECT userid FROM ^users
                         WHERE `email` LIKE #
                         LIMIT #',
                        '%'.$username.'%',
                        qa_opt('q2apro_ajax_usersearch_maxshow')                       
                    )
                );
                } else {
                $potentials = qa_db_read_all_assoc(
                    qa_db_query_sub(
                        'SELECT userid FROM ^users
                         WHERE `handle` LIKE #
                         LIMIT #',
                        '%'.$username.'%',
                        qa_opt('q2apro_ajax_usersearch_maxshow')                       
                    )
                );                   
                }

As admin you will then be able to search by email address. Simply sign out to search by username.
...