I'm trying to modify a login plugin to make new users to to enter the display name to show on the site when they register. I know that the display name is located in the wp-users table of the database, but cant seam to be able to write to it.
Edit
<?php
function wps_pro_login_registration_errors( $errors ) {
if ( empty( $_POST['first_name'] ) )
$errors->add( 'empty_first_name', '<strong>ERROR</strong>: Please enter your first name.' );
if ( empty( $_POST['last_name'] ) )
$errors->add( 'empty_last_name', '<strong>ERROR</strong>: Please enter your last name.' );
if ( empty( $_POST['nickname'] ) )
$errors->add( 'empty_nickname', '<strong>ERROR</strong>: Please enter your display name.' );
return $errors;
}
add_filter( 'registration_errors', 'wps_pro_login_registration_errors' );
function wps_pro_login_user_register( $user_id )
{
if (!empty($_POST['first_name']))
update_user_meta($user_id, 'first_name', $_POST['first_name']);
if (!empty($_POST['last_name']))
update_user_meta($user_id, 'last_name', $_POST['last_name']);
if ( !empty( $_POST['nickname'] ) )
update_user_meta( $user_id, 'nickname', $_POST['nickname'] );
}
add_action( 'user_register', 'wps_pro_login_user_register' );
?>
This works fine to write to wp_usermeta table but since the display name is in the wp_users table it does not work.
I've added the following with no success.
if ( empty( $_POST['displayname'] ) )
$errors->add( 'empty_displayname', '<strong>ERROR</strong>: Please enter your display name.' );
in the upper section and the following in the lower section
if ( !empty( $_POST['displayname'] ) )
update_user_meta( $user_id, 'displayname', $_POST['displayname'] );