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

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

You can just call get_user_meta without specifying a key, and it will return all MetaValues for the user. $userdata = get_user_meta( $userID ); You may have to do a mapping for displaytitles of the Metavalue, as they are returned in an array, where the keys are the databasevalues of your metakeys. For example, you may get ...


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

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

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


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

This is not a simple answer, so first you will need to include one more filter to allow you to grab both the make the meta_query interact with the main query via an OR instead of a AND, check my sample of code: add_filter('user_search_columns', 'q166419_user_search_columns' , 10, 3); function q166419_user_search_columns($search_columns, $search, $this){ ...


2

If you're looking to get in to instant notifications without suffering from backlog, I'd looking in to both Node.js and Socket.io. You should be able to work with them both pretty easily and integrate w/ WordPress. The sample chat application on the Socket.io site isn't a far cry from what you'd be doing. Basically an event is triggered on your LAMP/LNMP ...


1

It looks like you're using wrong parameters, please try this instead (untested): $q = new WP_User_Query( array( 'role' => 'contributor', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'first_meta', 'value' => '2', ), ...


1

Turns out that the correct key was icl_admin_language. I was able to drop the key from the "get_user_meta" function and then print_r the variable. This showed me all custom user meta which I could then sift through for my desired key.


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

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

Make sure to have identical keys in both of the arrays. Keys 'first_name', 'last_name' and respective keys 'fname', 'lname' are different. If you can make them identical then first do it, otherwise you will either need to do string manipulation for these keys before using them or put a condition like below in the foreach loop - foreach($user_meta_fields as ...


1

You are using "the_author_meta( 'description' )" inside loop or outside loop ? If you are using it outside loop kindly pass user id to id. <ul> <?php $blogusers = get_users('orderby=nicename&who=authors'); foreach ($blogusers as $user) { $user_info = get_userdata( $user->ID ); ?> ...


1

Edit: The meta_key is case insensitive by default because the default collation on the relevant tables is "utf8_general_ci", which uses case insensitive sorting for text comparisons. If you change the collation of the rows in the database, you can change the sort order and thus whether it is case sensitive or not. You can also use the DB_COLLATE define in ...



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