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

Post as someone else

If you’re logged into WordPress as an administrator, you can easily change the post author of a post to someone else. So what you’ll want to do is set up different user accounts for your different authors and then set yourself up as an administrator. Then when you go to publish a post using your … Read more

How to add user meta for all users

yes, you would have to loop through all users so that you could then update that user_meta field: // Create the WP_User_Query object $wp_user_query = new WP_User_Query(array(‘role’ => ‘Subscriber’)); // Get the results $users = $wp_user_query->get_results(); // Check for results if (!empty($users)) { // loop trough each author foreach ($users as $user) { // add … Read more

Get users order by meta key with limit

You can use get_users() with meta_key and order by meta value, descending. Example: $user_args = array( ‘meta_key’ => ‘points’, ‘number’ => 10, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ ); $top_users = get_users($user_args); NOTE: Support for meta_value_num is available only from version 4.2

How to query users who have empty first_name?

It looks like you’re searching for the first_name meta keys with empty string meta values: $options = array( ‘meta_query’ => array( array( ‘key’ => ‘first_name’, ‘value’ => ”, ‘compare’ => ‘=’, ), ) ); $users = get_users( $options ); that generates this kind of SQL query: SELECT wp_users.* FROM wp_users INNER JOIN wp_usermeta ON ( … Read more

trying to list users & display first – last name

first_name and last_name are stored in the usermeta table. Therefore you have to use get_user_meta() to return these data. Try this code snippet: $users = get_users(array( // blog_id is not required and will be set by WP_User ‘role’ => ‘sm_flagar’ )); foreach ($users as $user) { $firstName = get_user_meta($user->ID, ‘first_name’, true); $lastName = get_user_meta($user->ID, ‘last_name’, … Read more

How to get current user’s phone number

<?php // number 9 will be user ID $all_meta_for_user = get_user_meta( 9 ); print_r( $all_meta_for_user ); // find the key that you want Array ( [first_name] => Array ( [0] => Tom ) [last_name] => Array ( [0] => Auger) [nickname] => Array ( [0] => tomauger ) How to get current user’s phone number … Read more