[wp-hackers] Change default display name for new users
Otto
otto at ottodestruct.com
Mon May 7 21:41:52 UTC 2012
Put this in a plugin or something similar.
add_filter('pre_user_display_name','default_display_name');
function default_display_name($name) {
if ( isset( $_POST['display_name'] ) )
return sanitize_text_field( $_POST['display_name'] );
if ( isset( $_POST['first_name'] ) ) {
$name = sanitize_text_field( $_POST['first_name'] );
if ( isset( $_POST['last_name'] ) )
$name .= ' '. sanitize_text_field( $_POST['last_name'] );
}
return $name;
}
That will change the default display name at the time of user creation to
be firstname lastname.
-Otto
On Mon, May 7, 2012 at 3:11 PM, Robert Lusby <nanogwp at gmail.com> wrote:
> Is there a hook or filter that can be used to override the default display
> name? Can't seem to see on in the code, but sure I'm missing something.
>
> In my install it makes more sense for display_name to be first name + last
> name for all new users, rather than login name.
>
> Thanks,
> Robert.
> ______________________________**_________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> http://lists.automattic.com/**mailman/listinfo/wp-hackers<http://lists.automattic.com/mailman/listinfo/wp-hackers>
>
More information about the wp-hackers
mailing list