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

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

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


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 ...


3

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


2

I believe Crazycoolcam spelled the table incorrectly, user_meta vs usermeta. You may also want to define the else case, what happens if the table is not user. Try this: <?php $wpdb->add_database(array( //Connect to Users Database 'host' => DB_HOST, // I am using the same host for my two DBs 'user' => DB_USER, ...


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

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

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.


1

The way you suggest doing this, it won't ever be secure. If I understand you, just disabling Javascript would spoil the security. What you'd need to do is run a script that uses an AJAX request to query for and then add data to the page, but only if the user is logged in. That would fail safe if Javascript were disabled. However, that is also a very ...


1

This code works for me. It uses 'locations' custom taxonomy and 'suggest' javascript. You need to extend it to support multiple term selection. Add custom field to user-edit screen and store metadata when user/admin updates profile // for account owner add_action('show_user_profile', 'add_custom_user_profile_fields'); add_action('personal_options_update', ...


1

the_author_meta() is going to echo content directly. It will not pass a string back that can be processed by do_shortcode(). You want get_the_author_meta(), which is essentially the same as the_author_meta() but it returns a string instead of echoing the data.


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

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

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



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