9

You can filter 'wpmu_validate_user_signup' and check if the error code matches the 4 character warning. Then just unset the error code. Sample plugin: <?php # -*- coding: utf-8 -*- /* Plugin Name: Allow short user names for multi site. */ add_filter( 'wpmu_validate_user_signup', 'wpse_59760_short_user_names' ); /** * Allow very short user names. * *...


9

Okay, I found a solution (and it can be used for any theme, with any plugin as it only uses core WordPress functions). In the menu, name the menu item where you want the user's name to appear with a place-holder (see screenshot below). Example: #profile_name#, #user#, #random# Now, add the following code to the your child-theme's functions.php: function ...


8

The code: function give_profile_name($atts){ ... } gives a warning. Better is: function give_profile_name(){ ... } And it is better to detect if the user is logged in or not. Like so: function give_profile_name(){ $user=wp_get_current_user(); if(!is_user_logged_in()) $name = "User not logged in"; else $name=$user->...


7

There are two very different hooks you can use, depending on the installation: wpmu_validate_user_signup for multi-site and registration_errors for single-site. The following untested code shows how to use them. You can tweak the array in user_name_is_forbidden() to your needs. Use regular expressions for the matches. // multi-site add_filter( '...


7

I think the answer is in the source. $username = wp_strip_all_tags( $username ); $username = remove_accents( $username ); // Kill octets $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities // If strict, reduce to ASCII for max portability. if ( $strict ) $...


5

Try putting this in your functions.php function wpse60605_change_username_label( $defaults ){ $defaults['label_username'] = __( 'Username or Email' ); return $defaults; } add_filter( 'login_form_defaults', 'wpse60605_change_username_label' );


4

Using the regex posted by Moaz (and adding capitals), we will need to hook into the registration_errors filter: // Restrict username registration to alphanumerics add_filter('registration_errors', 'limit_username_alphanumerics', 10, 3); function limit_username_alphanumerics ($errors, $name) { if ( ! preg_match('/^[A-Za-z0-9]{3,16}$/', $name) ){ $...


4

The following untested code should get you started. Basically you add a display target on your form, add some javascript to add the validation when the user leaves the username field, and the server-side code to enqueue the javascript, and register the ajax actions. Let me know what breaks, as I'm sure this will not run out of the box. [!--HTML to add to ...


4

Looking on Trac I found a ticket that discusses exactly this issue: Administrator should be able to change usernames This is what it all boils down to: Changing usernames could break permalinks To prevent this a lot more than just changing the username in the DB would need to be done. E.g. redirection from old usernames. Caching Issues I quote from the ...


3

First: The $wpdb object has the names of tables, with prefixes, pre-defined for you. $wpdb->users == 'wp_users' $wpdb->posts == 'wp_posts' etc. Second: $wpdb-prepare() is essentially a WordPress aware printf, if you pass it more than one argument, you need to have some string/digit replacements %s %d $sql = "UPDATE {$wpdb->users} SET user_login ...


3

As there can be more than one error for user names, the accepted answer could remove errors we would want to preserve. For example entering a user name of 123 would now pass whereas it should presumably still give the error message 'Sorry, usernames must have letters too!' Modified sample code to fix this: /* Plugin Name: Allow short user names for multi ...


3

In the en_GB version of the .mo translation file, this string is available: <strong>ERROR</strong>: Invalid username. <a href=\"%s\" title=\"Password Lost and Found\">Lost your password</a>? and the reference is from wp-includes/user.php on line 93. I found this using Poedit and searching using Ctrl + F. From line 93 we get the ...


3

You can use @ and . in usernames, so there is no problem. Now you could create your own register form and use register_new_user(). You could even manipulate wp_registration_url() with the filter register_url, so the register link would point to your new register page. If you want to use it with the standard interface provided by wp-login.php, you would need ...


3

This will get you a first name + last name combination if available, or just the first name or last name if that's all your user submitted. This assumes you're interested in registered user's names. If you're going to add first and last names to your commenting form... or treat first + last name as "display name" from the back end forward (so possibly not ...


3

I just fund the tricky solution, it was very simple and I did think about it. I just went to WooCommerce -> Settings -> Accounts and I untick the checkbox for "Automatically generate username from customer email". I got the solution from this topic but here the problem was the contrary: https://stackoverflow.com/questions/32781569/remove-username-field-...


3

You can use the wp_pre_insert_user_data filter. function wpse_filter_user_data( $data, $update, $id) { if( isset( $data[ 'user_login' ] ) ) { $data[ 'display_name' ] = $data[ 'user_login' ]; return $data; } $user = get_user_by( 'email', $data[ 'user_email' ] ); $data[ 'display_name' ] = $user->user_login; return $data; } add_filter( '...


2

This is impossible to answer without seeing your code but there is no user_nickname in the $wpdb->users table and no user_nickname key in the $wpdb->usermeta table by default. Assuming that $users is a user object then: $users = $user_query->get_results(); foreach( $users as $user ) { echo get_user_meta($user->ID,'nickname',true); } ...


2

Try echo the_author_meta( 'nickname', $current_user->ID ); or you can also use; $current_user = wp_get_current_user(); echo $current_user->nickname ;


2

There are ways to trick WP into pre-populating the username field, but I'm pretty sure it would involve using POST and also tricking it into thinking there were errors in a previous submission. My advice would be to just use Javascript (or jQuery, as I've done below). It's still 'hacky', but at least it gets the job done with very little overhead and it's ...


2

Fixed it! There are two methods: // Force update our username (user_login) global $wpdb; $tablename = $wpdb->prefix . "users"; // method 1 //$sql = $wpdb->prepare("UPDATE {$tablename} SET user_login=%s WHERE ID=%d", $user_email, $user_id); //$wpdb->query($sql); // method 2 $wpdb->update( $tablename, array( 'user_login' => $user_email ), ...


2

We need to add a filter to 'sanitize_user'. Here is the sample code that will work for you. add_filter( 'sanitize_user', 'tubs_sanitize_user', 10, 3); function tubs_sanitize_user($username, $raw_username, $strict) { $new_username = strip_tags($raw_username); // Kill octets $new_username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $...


2

nickname field is one of the options made available for choice in "Display name publicly as" option in user profile. It has no other use in core code, as far as I know.


2

Spaces are not allowed in URLs, so WordPress uses the user_nicename for those links. The user nice_name is "A string that contains a URL-friendly name for the user. The default is the user's username.". That is a transformed user name such that it is all lowercase with spaces replaced by dashes. I did not look up what other transformations are probably ...


2

The filter validate_username sends and expects a boolean value, not a string. Hook into sanitize_user and use mb_strtolower(). Sample code, not tested: add_filter( 'sanitize_user', 'wpse_83689_lower_case_user_name' ); function wpse_83689_lower_case_user_name( $name ) { // might be turned off if ( function_exists( 'mb_strtolower' ) ) ...


2

In a multi-site installation it is 'wpmu_validate_user_signup': add_filter( 'wpmu_validate_user_signup', 'wpse_77904_mu_no_at_in_username' ); function wpse_77904_mu_no_at_in_username( $user ) { if ( FALSE !== strpos( $user['user_name'], '@' ) ) $user['errors']->add('user_name', __( 'That username is not allowed.' ) ); return $user; } ...


2

There is a note on the wp_udate_user function codex page: http://codex.wordpress.org/Function_Reference/wp_update_user. And that is: Please note that we cannot change the usernames through this function, in fact the usernames cannot be changed from the admin dashboard as well since WordPress does not allow the usernames to be updated. So you can't change ...


2

One alternative is to modify the $_POST['user_login'] input value when submitting new registration form, that is before WP process the registration form. A good hook to achieve this is login_form_register that fires before processing and rendering registration form. login_init also works but need more work to make sure we are on register action. add_action('...


2

Chris Haugen, You need to check user role who have 'artist' role and then you need to act on some video loop stuff. Here's the solution: $user = get_user_by('login', $username ); if ( !empty( $user->roles ) && is_array( $user->roles ) ) { foreach ( $user->roles as $role ){ if($role == 'artist') ...


2

No shortcode needed add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' ); function my_dynamic_menu_items( $menu_items ) { foreach ( $menu_items as $menu_item ) { if ( strpos($menu_item->title, '#profile_name#') !== false) { $menu_item->title = str_replace("#profile_name#", wp_get_current_user()->user_firstname, ...


2

How friendly are you with databases? The simpliest way is to change it in database directly. You need to check table WP_users and WP_users meta. Everything else is according to ID of that user and gravatar is checking your email so there is no problem in changeing it in database. Unfortunately you can't do it in wordpress from admin panel. It is restricted. ...


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