27. Juni 2011
von Blackbam

Leider ist der Eintrag nur auf English verfügbar.

Share

Dieser Eintrag wurde am 27. Juni 2011 um 23:23 in der Kategorie WordPress, WP Scripts veröffentlicht. Du kannst die Kommentare zu diesem Artikel mit RSS 2.0 abonnieren. Feedback, Diskussion, Lob und Kritik sind erwünscht: Kommentar schreiben oder Trackback anlegen.


Tags: , , ,

Bereits 39 Meinungen zu "(English) WordPress improved user search (first name, last name, email) in backend":

Book comments (RSS) oder URL Trackback

Jan Egbert   sagt:

am 05. Juli 2011 um 10:23 Uhr


Thank you for sharing this snippet. Works great. It would be even better if it also searched for parts of emailadresses. Let's say I'm searching for 'fred' and there is an email address registered called 'amazingfred88@amazingemailaddress.com'. I tested a case like this and it doesn't find fred now unles I search the exact email address.

Blackbam     sagt:

am 14. Juli 2011 um 00:18 Uhr


Hi there,
it took some time, but I found some time to improve the script today - now the search for e-mail addresses is working properly. Tell me if you experience any more bugs.

Jan Egbert   sagt:

am 24. August 2011 um 10:49 Uhr


This response to your efforts to make this script even better took over a month. Sorry about that. But the script really rocks now. No more '0 results' when I know that there must be a user somewhere who's called Fred.;) Why don't you add this to the plugin repository. I could also do it for you if you want. In that case I'll give you all credits.

Blackbam     sagt:

am 30. August 2011 um 11:53 Uhr


Hi Jan, I have requested to add the Plugin to the WordPress Plugin repository today, so it will hopefully be easy to find for everybody who wants to use it soon. It will be uploaded as soon as I get the confirmation.

Thank you for your help, if you want to and tell me your account name from wordpress.org, I can add you as a committer. Each of us can edit and improve the Plugin then, as well as answering questions.

Blackbam     sagt:

am 02. September 2011 um 18:14 Uhr


The Plugin is officially uploaded to the WordPress Plugin directory by now:
http://wordpress.org/extend/plugins/improved-user-search-in-backend/

peeayoo   sagt:

am 07. September 2011 um 14:31 Uhr


Hi Blackbam,

nice code. Small improvement from my perspective, either nothing critical.
instead of looping through all ids:

$id_string = "";
            $b = 0;
            foreach($uids as $aid) {
                if($b != 0) {
                    $id_string .= ",";
                }
                $id_string .= $aid;
                $b++;
            }


lets do it a little more fancy:

$id_string = implode("",$uids);


Thanks

p

Blackbam     sagt:

am 14. September 2011 um 13:21 Uhr


The new Version of the Plugin includes the Code improvements suggested by peeayoo as well as the possibility to search for custom user meta fields.

bren   sagt:

am 30. September 2011 um 02:09 Uhr


Hi Blackbam,

when trying to install the plugin WP reports an invalid header.
Posted by one user here
http://wordpress.org/support/topic/plugin-improved-user-search-in-backend-plugin-improved-user-search

Same problem here as well.
Tried installing manually and found that the folder and contents were there on FTP.
Tried all manner of hacking the header removed umlauts etc :o)
no luck :o(

Looking forward to a fix

thanks

Blackbam     sagt:

am 30. September 2011 um 14:02 Uhr


Hey there, this problem was suddenly appearing and I really did not understand it, as I changed nothing and I do not know how this happend. I am searching for a solution currently. I suppose, I made the mistake which is talked about here on Stackoverflow. The repository is a bit confusing sometimes :-/ Hopefully I can fix this in a few days.

white_buddah   sagt:

am 11. November 2011 um 17:36 Uhr


Hey Blackbam! I've find only your plugin for quick user's search and it's broken. This thing make me cry T_T I think that error happenes after Wordpress updates to 3.2.1 or smth Solution from StackOverflow doesn't work, I changed directory structure and put plugin manually via FTP but Wordpress don't even show plug in inactive plugins.. Dont know what to do. Maybe you know some alternative plugin with similar options? Thanx a lot!

Blackbam     sagt:

am 11. November 2011 um 18:45 Uhr


Hey there, nobody can answer me how to repair the broken repository, which is really sad. I don not understand why they use it. It seems to me, as using the repository is more difficult than writing good Plugins.

But here is a solution to use the Plugin anyhow, with installing it manually:

1. Download this a fixed version of the Plugin

2. Go to Plugins -> Add new in your WordPress backend

3. Upload the fixed Plugin and activate it

4. Enjoy

This should work, as it has in the test. It is exactly the same Plugin, but with some naming changes so WordPress thinks its another one. Hope this helps!

white_buddah   sagt:

am 11. November 2011 um 19:02 Uhr


Thank you for fast reply :)
Will try.

You did a great and useful job, Blackbam.

alicemdesign     sagt:

am 24. November 2011 um 11:33 Uhr


Thanks for the plugin! I uploaded your fixed version, however when I tried to use it in the Users section, I get a blank page -- no results, no table, nothing. Any ideas?

Blackbam     sagt:

am 24. November 2011 um 16:34 Uhr


Hey there,

the fixed version was tested with some WordPress installations, where problems didn't occur.

Where/when exactly did your error occur? When you submitted a keyword to search users?

Maybe more important: What version of WordPress do you use?

The Plugin hooks into the WordPress query, this might have changed with WordPress 3.3 (then this must be fixed) or is maybe different in older versions, so an invalid query might have been generated?

alicemdesign     sagt:

am 24. November 2011 um 21:05 Uhr


Hi! I'm using WP 3.2.1 and the site is www.proacttraining.com. The error occured when I submitted a keyword (by first name) to search users in the back end (all users). It seems it just gets stuck. thanks!!

Joshua     sagt:

am 30. November 2011 um 19:49 Uhr


Hey, I responded to your post on wordpress.org, but not sure if you saw it. I noticed that the svn version of your plugin contains old Mac-style line endings (\r), rather than Windows (\r\n) or unix (\n). When I manually converted it to unix-format, the plugin started working again. Your fixed version seems to have Windows-style endings. I am not sure if that is what is wrong with your plugin, but it might be worth changing to see if it fixes the issue.

Blackbam     sagt:

am 01. Dezember 2011 um 00:35 Uhr


@alicmedesign:

Hey there, as the Plugin seems to work for most users, it seems to be a specific problem regarding to your project. I recommend to to the following, which you should be able to do with some basic coding skills:

1. Take the function from this article and add it to your functions.php-file of your Theme

2. Add the following code in your functions.php, too:
add_action('pre_user_query', 'user_search_by_multiple_parameters');

3. You should remove the code for the meta fields.

If the Plugin is not working after doing this, there might be a problem with another Plugin. You can try deactivating all other Plugins and check if the Plugin is working now. If it is still not working, your WordPress installation might have been modified or is broken, as the Plugin works with other versions of WP 3.2.1.

Blackbam     sagt:

am 01. Dezember 2011 um 00:44 Uhr


@Joshua:

Hey Joshua, thanks a lot for your advice! I will check this problem soon.

Can you tell me, how you found out this thing with the line endings? What tool did you use?

Joshua     sagt:

am 05. Dezember 2011 um 22:54 Uhr


@Blackbam I do a lot of work with the vi editor on remote FreeBSD servers, which only supports the \n line endings, and shows special characters for the other line endings. If you use Windows for development, I tend to use Notepad++ (http://notepad-plus-plus.org/), which tells you what type of line ending the file has in the status bar.

Gennady   sagt:

am 08. Dezember 2011 um 10:09 Uhr


@Blackam, great plugin, although it didn't work for a multisite network out of the box. The thing is that when you use $wpdb->prefix the prefix is that of a blog (like wp_1_ or wp_2_ or wp_3_ and so on); multisite database tables do not have a users and usermeta table, they share the main site table with a wp_ (by default) prefix. So I had to change $wpdb->prefix to $wpdb->base_prefix which gives the base prefix in order for it to provide legal queries to existing tables. And yes, like @Joshua said, the plugin would not detect, I had to copy and paste the code between the tags into a new file.

Gennady   sagt:

am 08. Dezember 2011 um 10:20 Uhr


Another thing, David, that I personally did was lowercase the $_GET['s'] and LOWER() all query values in order to achieve case insensitive matching. LOWER(meta_value) LIKE... and LOWER(user_email) LIKE... etc. Also mysql_string_real_escape could only be done once in the beginning to save some cycles, except you have to keep the original query string intact in the final replace of the query_where part, otherwise it will not work. Again, good work! Thanks for this plugin.

Blackbam     sagt:

am 08. Dezember 2011 um 11:48 Uhr


Thank you, for your advices so far. The thing with the line endings did not fix the problem, and neither did fixing the tags in the repository so far. But I will keep trying, maybe I forgot something.

@Gennady: Your improvement ideas will be integrated into the next update, possibly as settings in the options page.

Joshua     sagt:

am 15. Dezember 2011 um 01:47 Uhr


@Blackbam I just did another checkout of your code from the svn repo, but it said nothing had been changed. How did you test this? If you would like, I might be able to try fixing the line endings on my side, and committing them to your wordpress plugin repository, although I am not sure if I can do that with my account or not.

Blackbam     sagt:

am 15. Dezember 2011 um 02:31 Uhr


@Joshua: Help would be really appreciated!

Tell me your WordPress.org Username and I will add you as a comitter to the Plugin. If you do not want to show it publicly here, send an email to admin@blackbam.at.

Joshua     sagt:

am 15. Dezember 2011 um 21:52 Uhr


@blackbam My wp username is jwhyatt

Blackbam     sagt:

am 16. Dezember 2011 um 02:06 Uhr


@Joshua: You have been added. You hopefully can connect to the repository now and try to fix it.

Joshua     sagt:

am 16. Dezember 2011 um 18:56 Uhr


@Blackbam I checked in a new version that seems to activate correctly now. Hopefully it won't cause you any more issues, and thanks for the great plugin.

Blackbam     sagt:

am 16. Dezember 2011 um 21:54 Uhr


Great, thanks to @Joshua the repository is repaired now!

So the new features will be implemented within some weeks now, too.

DW   sagt:

am 17. Januar 2012 um 19:46 Uhr


Sorry for the newb question, but do I have to add this code if I've installed the plugin? Also, is there a specific place I should add the code within functions.php? Thanks dw

Blackbam     sagt:

am 17. Januar 2012 um 20:00 Uhr


Hey, first of all you do NOT have to add any code to your functions.php if you install the Plugin. The code is published here, so that developers can see instantly how the Plugin works and possibly post improvement ideas.

Use the Plugin, not the code.

The code will not do anything if you paste it into your functions.php, unless you hook it into WordPress (Hook: 'pre_user_query') anyway.

Wassim   sagt:

am 04. März 2012 um 18:51 Uhr


Hi, I think it is a great but when I try to add a Custom Meta Fields i.e. "GENDER" it becomes \'GENDER\' Is there a solution for this. Thx

Blackbam     sagt:

am 04. März 2012 um 20:18 Uhr


Hey, because of some reason your blog added slashes to the options. I released a new version which validates the input of the meta fields, including stripslashes. Just download the new version and the problem should be gone.

Wassim   sagt:

am 05. März 2012 um 14:46 Uhr


Hi Blackbam I downloaded the update, but now when I tried to use "GENDER", "BLOODTYPE", "LOH" I received the following error. Illegal characters in Custom Meta Fields detected, the string was sanitized.

Blackbam     sagt:

am 05. März 2012 um 17:04 Uhr


Hello, you should not use quotes in your meta keys, as this can make problems with Queries. You are aware of, that these "keys" are the meta_key values of the wp_usermeta table right?

I do not think it is a good idea to have quoted meta keys, so i dissallowed meta keys containing non-alphanumeric characters, this is also for security reasons. Maybe this was a little bit to restrictive, so now the fields are escaped before the database query is done. There is no way around escaping quotes.

Wassim   sagt:

am 05. März 2012 um 18:20 Uhr


Hi.. I used quotes because the following is mentioned Add custom user meta fields from your usermeta table for integration in the user search (e.g. "url", "description", "aim", or custom like "birthday") I have created extra fields with Cimy User Extra Fields, I have used the database names and the label names but none worked

Blackbam     sagt:

am 05. März 2012 um 21:49 Uhr


Hey, there is quite an easy explanation for this. Cimy user extra fields is one of these Plugins creating own tables, instead of using the wp_usermeta table for storing user information. Therefore it is not possible for this plugin to find the user fields.

Maybe I will implement an extension for Cimy user extra fields soon, but the Plugins do not work together yet.

Wassim   sagt:

am 05. März 2012 um 23:21 Uhr


N problem, thx for the reply

Rénald Casagraude   sagt:

am 11. Mai 2012 um 19:44 Uhr


Hi,

Thanks for your plugin.

You should change tables references to increase compatibility :

$wpdb->base_prefix."users" should be $wpdb->users
$wpdb->base_prefix."usermeta" should be $wpdb->usermeta

I’ve notice some spaces around the "->" operator, I think that you should remove them.

Blackbam     sagt:

am 13. Mai 2012 um 23:24 Uhr


Hey, thanks, your improvement suggestions have been implemented in the new version 1.2.3.

Sag deine Meinung! Kommentiere: