Can’t add users in admin after copying database

The key turned out to be that the wp_users table lost its AUTO_INCREMENT setting when it was imported, for unknown reasons; the server may have timed out, etc. I found this out from the wp-cli error in the debug log that said “WordPress database error Duplicate entry ‘1000075’ for key ‘PRIMARY’ for query INSERT INTO … Read more

get_users(…) only returns one user

The include key on get_users requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you … Read more

Get current logged in user under 3.1, re: remove “Howdy”

Why fiddle around with jQuery when you could just run a filter on gettext to specifically target that text? Perhaps you simply don’t know you can do that, so here’s how.. add_filter( ‘gettext’, ‘change_howdy_text’, 10, 2 ); function change_howdy_text( $translation, $original ) { if( ‘Howdy, %1$s’ == $original ) $translation = ‘Logged in as %1$s’; … Read more

How to make user accept license agreement before download

Not being able to find anything I finally went ahead and created the WordPress plugin Terms before download. From the plugin’s description: Terms Before Download adds a shortcode that can be used instead of HTML anchors to link to downloadable files. If such a link is clicked a popup dialog shows terms and conditions (EULA) … Read more

How can I display show/hide elements when user is registered?

There is no way to do this based on registered vs unregistered status because all users are anonymous until they log in. If you mean “logged in” vs “not logged in” then … if (is_user_logged_in()) { // logged in content } else { // not logged in content } Reference: http://codex.wordpress.org/Function_Reference/is_user_logged_in