Nickname, Display Name – Public Name
Author | Posts |
---|---|
April 8, 2013 at 5:46 pm 1927 | |
strangerrj | Hi guys, I have to say that is not the nickname in the profile of the Public Name / Display Name of the user. Where can this be changed. As with everywhere eg. author postlink the display name. Thank you cheers |
April 8, 2013 at 7:40 pm 1937 | |
Tareq Hasan | Sorry, I didn’t understand your question. |
April 8, 2013 at 7:42 pm 1939 | |
strangerrj | Ok, in the profile, you can select the display name not the one that is shown to the public.
This is not the nickname.
In the free version it is installed. Nick and DisplayName.
Cheers |
April 8, 2013 at 7:45 pm 1941 | |
strangerrj | Here is the code excerpt from the free version:
<tr>
<th><label for=”nickname”><?php _e( ‘Nickname’ ); ?> <span class=”description”><?php _e( ‘(required)’ ); ?></span></label></th>
<td><input type=”text” name=”nickname” id=”nickname” value=”<?php echo esc_attr( $profileuser->nickname ) ?>” class=”regular-text” /></td>
</tr>
<tr>
<th><label for=”display_name”><?php _e( ‘Display to Public as’ ) ?></label></th>
<td>
<select name=”display_name” id=”display_name”>
<?php
$public_display = array();
$public_display[‘display_username’] = $profileuser->user_login;
$public_display[‘display_nickname’] = $profileuser->nickname;
if ( !empty( $profileuser->first_name ) )
$public_display[‘display_firstname’] = $profileuser->first_name;
if ( !empty( $profileuser->last_name ) )
$public_display[‘display_lastname’] = $profileuser->last_name;
if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) {
$public_display[‘display_firstlast’] = $profileuser->first_name . ‘ ‘ . $profileuser->last_name;
$public_display[‘display_lastfirst’] = $profileuser->last_name . ‘ ‘ . $profileuser->first_name;
}
if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn’t duplicated elsewhere
$public_display = array(‘display_displayname’ => $profileuser->display_name) + $public_display;
$public_display = array_map( ‘trim’, $public_display );
$public_display = array_unique( $public_display );
foreach ($public_display as $id => $item) {
?>
<option id=”<?php echo $id; ?>” value=”<?php echo esc_attr( $item ); ?>“<?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
<?php
}
?>
</select>
</td>
</tr>
|
April 9, 2013 at 9:48 am 1956 | |
strangerrj | Where can I find the form element button “Display Name”?
Thanks and greetings |
April 9, 2013 at 9:55 am 1958 | |
Tareq Hasan | The display name is not available in the form, but in can be done. Wait for a while, I’ll give you a code snippet that might solve your problem. |
April 9, 2013 at 9:56 am 1959 | |
strangerrj | Ah ok. Thanks. |
April 9, 2013 at 2:15 pm 1965 | |
Tareq Hasan | Add a Action Hook field in your form and give the hook name as [php] <div class="wpuf-fields"> if ( !empty( $profileuser->first_name ) ) if ( !empty( $profileuser->last_name ) ) if ( !empty( $profileuser->first_name ) && !empty( $profileuser->last_name ) ) { if ( !in_array( $profileuser->display_name, $public_display ) ) { $public_display = array_map( ‘trim’, $public_display ); foreach ($public_display as $id => $item) { add_action(‘wpuf_user_display_name’, ‘wpuf_user_display_name’ ); function wpufe_save_display_name( $user_id ) { add_action( ‘wpuf_update_profile’, ‘wpufe_save_display_name’ ); |
April 9, 2013 at 3:17 pm 1966 | |
strangerrj | Super, thank you very much. Works beautifully. Greetings |