Hot answers tagged

4

The rich_editing user option stores this check box value: wether or not do enable the visual editor for that particular user. If it's disabled then the content editor will look like this:


3

get_users() does not allow you to directly sort by whatever you like, but there are ways around it. The Codex for get_users() says: orderby - Sort by 'ID', 'login', 'nicename', 'email', 'url', 'registered', 'display_name', 'post_count', 'include', or 'meta_value' (query must also contain a 'meta_key' - see WP_User_Query). meta_value is a very powerful ...


3

I tested your code in both Wordpress 4.4 and in Wordpress 4.3.1. With version 4.4, I encounter exactly the same issue as you. However, your code works correctly in version 4.3.1! I think this is a Wordpress bug. I don't know if it's been reported yet. I think the reason behind the bug might be that the submit button is sending the query vars twice. If ...


3

What Caused the Problem The problem was that the restrict_manage_users action gets called twice: once ABOVE the Users table, and once BELOW it. This means that TWO select dropdowns get created with the same name. When the Filter button is clicked, whatever value is in the second select element (i.e. the one BELOW the table) overrides the value in the first ...


3

In the core, the bottom input names are marked with the instance number, e.g. new_role (top) and new_role2 (bottom). Here are two approaches for a similar naming convention, namely course_section1 (top) and course_section2 (bottom): Approach #1 Since the $which variable (top,bottom) doesn't get passed to the restrict_manage_users hook, we could get around ...


2

There is the action hook user_register that is called immediately after a user is added to the database. The user id is passed to the hook as an argument. You can use wp_insert_post to insert a new post in that action. You just need to get the relevant info from the user and add it to the post. You can add custom fields to the post you create by referencing ...


2

Finally I found answer by myself. Let's explore it with two user meta's current_login, last_login.Lets see the code. //function for setting the last login function set_last_login($login) { $user = get_userdatabylogin($login); $curent_login_time = get_user_meta( $user->ID , 'current_login', true); //add or update the last login value for ...


2

Roles First of all you need to register the 2 roles, look at add_role. When you register the role, you are free to assign any capability you want. Only be careful to add the roles when your theme / plugin is activated and possibly remove them (see remove_role) when it is disabled. Meta Data You can do the association using a meta entry like ...


2

You're close - just need to tweak your arguments: <?php echo get_user_meta( $customer_id, 'billing_phone', true ) ?> Just make sure $customer_id is the ID of the user - you probably want get_current_user_id() instead.


2

There's no built-in functionality to append meta values you'll need to do it manually. If you plan on adding multiple values I would suggest saving it as an array but it will serialize it in the database which will make it harder to run WP_Meta_Query on. $user_id = fav_authors_get_user_id(); $fav_author_id = 2; $author_list = get_user_meta( ...


2

There is no tax_query parameter for the WP_User_Query class. Since you've tagged the question with user-meta I can only assume you store the ID (or even the term name itself?) of a particular shop-category term as a user meta entry. In this case you would need something like this: // The 'WP_User_Query' arguments array $args = array( 'role' ...


2

You probably haven't changed the display name, which is probably what is being displayed. "nicename" is used for the author's posts page url and not for display. UPDATE wp_users SET display_name = replace(display_name, @old_user, @new_user);


1

You have not provided the whole code so don't understand where you are wrong, this script is working fine for me. add_action( 'personal_options_update', 'save_extra_profile_fields' ); add_action( 'edit_user_profile_update', 'save_extra_profile_fields' ); function save_extra_profile_fields( $user_id ) { if ( current_user_can('edit_user',$user_id) ) ...


1

@Cristián Lávaque Thank you for the hints ;) Actually I managed to resolve the issue blocking this function (show the hidden comment above). In case this would help anyone here is the final working code: function check_post_limit() { if ( current_user_can( 'edit_posts' ) ) { global $userdata; global $wpdb; ...


1

User meta information, like that on the profile page, is stored in the usermeta table in the database. You can add extra fields by hooking into the show_user_profile and edit_user_profile action hooks. Then you can save the information by hooking into the personal_options_update and edit_user_profile_update action hooks with a function that updates the new ...


1

Thanks yo Howdy_McGee, Here is working code. // Remove favorite authors from current users DB function fav_author_remove_user(){ check_ajax_referer( 'fav_authors_obj_ajax', 'security' ); $remove_this_author = $_POST['clicked_author_id']; if ( current_user_can( 'edit_posts' ) ){ $user_id = fav_authors_get_user_id(); $author_list ...


1

This is my working code based on @bybloggers answer (thanks by the way) I just learn that we shouldn't be using template_redirect hook and then exiting php, because some things may stop working because the abrupt interruption of php executing code. The explanation is here: ...


1

You can store the ratings as user meta. When a rating is added, add it to the user's ratings using add_user_meta(): add_user_meta( $user_id, '_ratings', $rating, false ); The last parameter tells it to add the current rating to the meta as a new item, not to replace the existing. All ratings can then be retrieved using get_user_meta(): get_user_meta( ...


1

Two options. The first will keep you away from custom SQL, and should be a lot more efficient than what you currently have. It runs two queries, one to get the user ID with the highest hourly rate, and then again to get the lowest. You need one more query to update the user meta cache & then you're home free: $query = new WP_User_Query; $users = array( ...


1

Try this: $yoursearchquery = 'This is my search'; $users = new WP_User_Query(array( 'search' => $yoursearchquery, 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'shoe_size', 'value' => $yoursearchquery, 'compare' => 'LIKE' ), array( 'key' ...


1

In general your problem is that you check the condition on the front end but not on the backend. You have to check if a user is a allowed to upload a file before moving it to the uploads directory and adding it as an attachment. If the limitation you put are kind of nice to have it might be enough to limit upload in the UI, but if it has business or law ...


1

This will do what you want, and both functions should be placed within your fucntions.php file. The my_random_string() function accepts arguments, so you can add data before/after the string, as well as change the length of the string and the characters that are used to generate the string. /** * Generate a string of random characters * * @param array ...


1

First You can get rid of nasty globals in your AJAX call. I'm not sure what the $st variable that you were output is all about so I've excluded, but you can include as you wish - add_action('wp_ajax_change_subscription', 'change_subscription'); function change_subscription(){ if(!empty($_POST['term_id']) && !empty($_POST['type'])) : ...


1

If I understand problem correctly, you want to store name of multiple files in user meta field. add_user_meta function has fourth argument $unique which is false by default that means for each call to add_user_meta a new key-value pair is added, even if key already exists. add_user_meta has less clarification then the add_post_meta that does exactly same ...


1

You can use get_current_user_id() - if a user is not logged in, the value will be 0: <a href="http://example.com/uid=<?php echo get_current_user_id() ?>">...</a>


1

What is the exact meta_key and meta_value for the field I created using the function custom_user_profile_fields ? created_by and some user ID, for example: $args = array( 'meta_key' => 'created_by', 'meta_value' => 123, ) You could use a meta_query for more complex searches. $args = array( 'meta_query' => ...


1

Edit the user in phpmyadmin, enter the password as text in the user_pass field and there is a “Function” column with drop down boxes. On this field just select MD5 in the function column. When you save it phpMyAdmin will automatically md5 hash it for you.


1

I could only find the following core code references for the meta-box-order_ string: /wp-admin/includes/ajax-actions.php: update_user_option($user->ID, "meta-box-order_$page", $order, true); and /wp-admin/includes/template.php: ... get_user_option( "meta-box-order_$page" ) ... that's related to the ordering of meta-boxes. I doubt your ...


1

Please add following condition. $mailSent = get_user_meta($us_id, 'mail_sent', true); if($mailSent){ update_user_meta($us_id, 'mail_sent', 'mail sent'); }else{ $borrower_mail=wp_mail($to, $subject, $body); }


1

Try this: global $current_user; $user_id = $current_user->ID; // current user ID $meta = get_user_meta( $user_id, 'title', 'Manager' ); // subject meta if($meta != '') // updates meta if exists update_user_meta($user_id, 'title', 'Manager'); else // creates new meta if not exists add_user_meta($user_id, 'title', 'Manager');



Only top voted, non community-wiki answers of a minimum length are eligible