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

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

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

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.


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

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


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


1

In WordPress is simple specific capabilities to specific user roles, and also create custo roles. In my plugins I often creata a user roles that have all my pugin specific capabilities, and the attach some cap to some role and som caap to other. Once you have no made a specific request I'll give you an example, that I think will help you facing this ...


1

Okay.. you COULD add a button like you mentioned; but I think this is going to require a lot more code. The users.php page is using the WP List Table class.. which means we can hook into the bulk actions and add our custom value there. So, let's create a function to add a new value into the bulk actions dropdown box: add_action('admin_footer', ...


1

First of all get_users_of_blog has been deprecated, so you should use get_users instead, or run a WP_User_Query. After that, the_author_meta echo the meta value, not return anything. To return the meta you should use get_the_author_meta() $blogusers = get_users( $args ); // for args see codex if ($blogusers) { foreach ( $blogusers as $bloguser ) { ...


1

You need to add the new merge tags with the gform_custom_merge_tags filter, and then replace them with the gform_replace_merge_tags filter, like this: Edit: you need to use the gform_field_content filter to replace the field's default value, see below. add_filter('gform_custom_merge_tags', 'wpse_121476_custom_merge_tags', 10, 4); ...


1

In your case $registered is the user id not the user object so it does not work. Please use the code as given below. add_action( 'user_register', 'set_user_registration_date', 10, 1 ); function set_user_registration_date( $user_id ) { $user = get_userdata ( $user_id ); // Update the registration meta data update_user_meta ( $user_id, ...


1

Okay, there are a couple of things to do: Get last_active for the user Calculate the days since last_active Set last_active_days_ago for the user So you can go like this: function daysAgo( $time ) { $time = time() - $time; $daysAgo = $time / 86400; // calculate days return $daysAgo; } function set_user_last_active_days_ago( $user_id ) { // ...


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


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.


1

Maybe you can try get_user_meta($user->ID, $course_field_name, true) ? By default, get_user_meta() returns an array See http://codex.wordpress.org/Function_Reference/get_user_meta


1

You should take a look at the first example for the shortcode_atts() page in the Codex: function bartag_func( $atts ) { extract( shortcode_atts( array( 'foo' => 'no foo', 'bar' => 'default bar', ), $atts, 'bartag' ) ); // etc... That great little function parses and sets defaults for a shortcode with two potential ...


1

To display the user meta data in the User's page, you need the filters manage_users_custom_column and manage_users_columns: Sortable Custom Columns in User Panel (users.php)? And to add the fields in the User/Profile pages, the following (from Checkboxes in registration form): // PROFILE add_action( 'show_user_profile', 'user_field_wpse_87261' ); ...



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