This topic contains 15 reply and 3 voices, and was last updated by Emil 4 years, 11 months ago
Viewing 15 Posts - 1 through 15 (of 15 total)
Author Posts
April 11, 2013 at 5:31 pm 2050
Emil Is there a way to make the display name default to the nickname set in a form?
April 12, 2013 at 1:26 am 2060
Tareq Hasan Tareq Hasan

Might be done, adding some code with wpuf_update_profile action hook.

April 12, 2013 at 11:13 am 2080
Nathan Nathan

Would it be possible to elaborate?

April 12, 2013 at 1:07 pm 2084
Tareq Hasan Tareq Hasan

[php]
function wpufe_set_nick_as_disp( $user_data ) {
if ( isset( $_POST[‘nickname’] ) ) {
$user_data[‘display_name’] = $_POST[‘nickname’];
}

return $user_data;
}

add_filter( ‘wpuf_update_profile_vars’, ‘wpufe_set_nick_as_disp’ );
[/php]

Should work.

April 12, 2013 at 1:23 pm 2085
Nathan Nathan

I’m afraid this did not 🙁

April 12, 2013 at 1:37 pm 2086
Tareq Hasan Tareq Hasan

Working for me, are you using the latest version of the plugin?

April 12, 2013 at 1:38 pm 2087
Nathan Nathan

I believe so, could this be the global post issue I’ve run into a few times before?

April 12, 2013 at 1:44 pm 2089
Tareq Hasan Tareq Hasan

No, there isn’t any global $post issue in this case.

April 12, 2013 at 2:05 pm 2091
Nathan Nathan

Just checked again – definitely not working. Is it because the first and last name are also set?

April 12, 2013 at 2:22 pm 2092
Tareq Hasan Tareq Hasan

That doesn’t make sense, no it doesn’t depends on first and last name. Do you have this word wpuf_update_profile_vars in /class/frontend-form-profile.php ?

April 12, 2013 at 2:32 pm 2094
Nathan Nathan

Yep. Would this work on registration, or only on updating a profile?

April 12, 2013 at 2:46 pm 2098
Tareq Hasan Tareq Hasan

As you have it, it should work, I don’t find any reason why it’s not working. May be try with default theme? It’ll work only when updating the profile.

April 12, 2013 at 2:55 pm 2100
Nathan Nathan

Ah that would be why! Anyway to make that work on registration?

April 12, 2013 at 3:04 pm 2103
Tareq Hasan Tareq Hasan

It’s a different function for registration.
[php]
function wpufe_set_nick_as_disp_reg( $user_id ) {
if ( isset( $_POST[‘nickname’] ) ) {
wp_update_user( array( ‘ID’ => $user_id, ‘display_name’ => $_POST[‘nickname’] ) );
}
}

add_action( ‘user_register’, ‘wpufe_set_nick_as_disp_reg’ );
[/php]

April 12, 2013 at 4:42 pm 2107
Nathan Nathan

Awesome! That did the trick!

November 18, 2014 at 5:28 pm 30699
Emil Emil

Hi – just had the same problem and this really worked well – thanks!

Hoverer, it doesn’t work when I try to update the nickname. Then it still shows the old nickname and not the new one. How do I fix that?

Viewing 15 Posts - 1 through 15 (of 15 total)