Tag Info

Hot answers tagged

7

user_nicename is url sanitized version of user_login. In general, if you don't use any special characters in your login, then your nicename will always be the same as login. But if you enter email address in the login field during registration, then you will see the difference. For instance, if your login is user@example.com then you will have ...


4

First of all, you ned a function (template tag) to display the url. You can write a custom function that output the url in the format you want, however, putting the username in a public url can be a security issue. The function can handle the link and accept an argument $user that can be a user id or a user object. If non is passed, the function will try to ...


3

Simple difference, user_login is used to validate login to the site, while user_nicename is used to create Author Permalink, Post Permalink


3

wp_insert_user returns your new user's ID, if created successful. You can add the user_meta to this ID: $userid = wp_insert_user( $userdata ); if ( !is_wp_error( $userid ) ) { // check if insert was successful add_user_meta( $userid, 'verification_ref', $ref ); // add the meta } else { /* Error Handling */ }


3

I came across a tutorial about 'Custom User Taxonomies in WordPress' and there is a plugin based on that 'User Taxonomies' but these are for creating taxonomies for Users. Have a read thought the tutorial it might help. I think what you're talking about is to associating posts' taxonomies with users. I think you need to use something like ...


3

This is not a WooCommerce question. Once the user is registered you use WordPress functions to verify whether the user is logged in and to retrieve the user's info. Assuming you are saving the user info correctly, then this should show a user's first name to the user, and a generic message to a non-logged-in user. if ( is_user_logged_in() ) { ...


3

I have tested your code on my side, and it works perfectly. The relevant info displays, whether I'm logged in or not. This is definitely not a problem with your code, but more an external problem. You will need to look for any type of code that might restrict this code from showing if a user is logged out, something like if ( is_user_logged_in() ). If you ...


2

Do you have any data showing that user meta won't work? Until you do — don't mess with it. You are not likely to get from-scratch solutions as convenient and more performant without significant effort.


2

If you check out the documentation for the update_user_meta() function, you'll note that the $meta_value parameter already accepts objects and arrays, so you can simply save a user's positions in an array without any additional effort: update_user_meta( 22, 'position_names', array( 'Khaleesi of the Great Grass Sea', 'Breaker of ...


2

Maybe start searching for plugins like Wishlist-Member, its description will give you the jargon and wordpress-specific ideas you'll need to better refine your search and move forward in your solution.


2

You need to create your own hook for registration_errors filter: add_filter( 'registration_errors', 'wpse8170_registration_errors', 10, 3 ); function wpse8170_registration_errors( $errors, $sanitized_user_login, $user_email ) { if ( /* something happens */ ) { $errors->add( 'myexception_code', 'This is my message' ); } return ...


2

Take a look at the WordPress Codex: Customizing The Registration Form Theme and plugin developers can customize WordPress's built-in user registration page through the use of hooks. Customizing the registration form involves utilizing the following three hooks: register_form Allows rendering of new HTML form elements. ...


2

Actually I found this to be more strait forward and simpler: //add columns to User panel list page function add_user_columns($column) { $column['address'] = 'Street Address'; $column['zipcode'] = 'Zip Code'; return $column; } add_filter( 'manage_users_columns', 'add_user_columns' ); //add the data function add_user_column_data( $val, ...


2

Why don't use built-in functionality of PHP? Put the following line right before the foreach: usort($members, create_function('$a, $b', 'return strnatcasecmp($a->last_name, $b->last_name);')); References: usort create_function strnatcasecmp


2

Try this: $user_data = get_userdata( $user_id ); $user_data->{'date-of-birth'}; It's weird looking but should work. :-)


2

How can I write a bulk MySQL command to add in the value wp_capabilites='a:1:{s:10:"subscriber";b:1;}' into each user_id except 1, 2 and 3 ie. the newly imported users? You don't. That is a serialized array which is a PHP construct. MySQL has no idea what to do with it. To the database, it is just an string. To PHP it is a representation-- a ...


2

I think I figured this one out. I had misread this answer and hooked the function I wrote to wp_clear_auth_cookie (actually a function itself!) instead of clear_auth_cookie (the real hook), so that wasn't working. But now using the real hook, I think it might be. Correct me if I'm wrong. Below is the function with the hook. function users_last_login() { ...


1

You have already found out that using update_user_meta() if the meta field for the user does not exist, it will be added. ie update_user_meta() can do the task of add_user_meta() However, the difference between them is the return values update_user_meta() returns False if no change was made (if the new value was the same as previous value) or if the ...


1

After a lot of trial and error I learnt that WP_User_Query takes an argument fields which can be set to 'all_with_meta'. This reduces number of queries to two for any number of users that are fetched in a single go and also provides benefits of caching. Usage would look like: $user_query = new WP_User_Query( array('include' => $post_authors, 'fields' ...


1

You don't need a checkbox, you can code one if you want, but you can use the default Custom Fields. Make sure they are enabled: Then add some data on the posts you want to have a specific style on, you will need to add this to each post you want to have set to display: none;: Now inside the loop of your page you will add that value as a CSS class: ...


1

The following code will display "Biographical Info" in "Add User" form function display_bio_field() { echo "The field html"; } add_action('user_new_form', 'display_bio_field');


1

You made a lot of statements here, so let's go through them bit by bit. while keeping database queries low The amount of queries isn't directly an issue, time that they take is. Single really slow query can take more time than hundreds of very fast ones. before the website loads (or the first time a website loads) Since WP is PHP application ...


1

When you pass three separate values for neww, the value ends up being the last one. So neww would need to be an array to collect all three: neww[] <input type="checkbox" name="neww[]" class="neww" value="one" /> <input type="checkbox" name="neww[]" class="neww" value="two" /> <input type="checkbox" name="neww[]" class="neww" value="three" ...


1

I normalize the output of these functions using this logic: Cast the value to an array. If it is not an array already, it will be converted to an array with one element, which is the value it was, e.g. (array) false becomes array (false). Use array_filter, which, when not passed a callable, simply filters falsy values from the array. Here is this logic ...


1

You will need to do a JOIN on the users table in your old database, and also select the display name. One key thing to note here, is that I aliased dbold_posts as P, and dbold_users as U - when dealing with multiple table, it's always best practice to specify which table you are referring to when mentioning a column. SELECT P.post_author, count(P.ID) as ...


1

Not with wp_create_user(). Check the source: 1518 function wp_create_user($username, $password, $email = '') { 1519 $user_login = wp_slash( $username ); 1520 $user_email = wp_slash( $email ); 1521 $user_pass = $password; 1522 1523 $userdata = compact('user_login', 'user_email', 'user_pass'); 1524 return ...


1

You can use the hook user_register to modify user data upon registration. You can use the function add_user_meta to add custom data to a user. Example: add_action('user_register', 'add_pin_number', 10, 1); function add_pin_number($user_id) { add_user_meta( $user_id, 'pin_number', $random_number , true ); } You can look for php function out there to ...


1

According with Wordpress documentation, if a user ID is pass to the wp_insert_user() function, it will try to modify the user with that ID if exists, but a new user won't be created. You sould store the facebook ID as user_meta.


1

Try this one with additional join on metadata SELECT u.ID, u.display_name FROM wp_users u LEFT JOIN wp_usermeta um1 ON u.ID = um1.user_id LEFT JOIN wp_usermeta um2 ON u.ID = um2.user_id WHERE um1.meta_value= 'value1' AND um1.meta_key = 'key1' AND um2.meta_key = 'keyA' AND um2.meta_value = 'valueA' GROUP BY u.ID Also use group by


1

To add data to the form at user-new-php, I believe you want the user_new_form hook. Unfortunately, it is marked "@since 3.7.0" so it isn't in the stable release yet. I am tempted to tell you to hack it into your site in exactly the place that it will soon appear, but that would be wrong. :) You will have to wait, or install the subversion release.



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