Home Forums Plugin Support WP User Frontend (Free Version) Default Display Name

This topic is: resolved

This topic contains 15 replies, has 3 voices, and was last updated by  Emil 4 years, 6 months ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #2050

    Nathan
    Participant
    Post count: 32

    Is there a way to make the display name default to the nickname set in a form?

    #2060

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #2080

    Nathan
    Participant
    Post count: 32

    Would it be possible to elaborate?

    #2084

    Tareq Hasan
    Keymaster
    Post count: 2831

    [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.

    #2085

    Nathan
    Participant
    Post count: 32

    I'm afraid this did not ๐Ÿ™

    #2086

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #2087

    Nathan
    Participant
    Post count: 32

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

    #2089

    Tareq Hasan
    Keymaster
    Post count: 2831

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

    #2091

    Nathan
    Participant
    Post count: 32

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

    #2092

    Tareq Hasan
    Keymaster
    Post count: 2831

    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 ?

    #2094

    Nathan
    Participant
    Post count: 32

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

    #2098

    Tareq Hasan
    Keymaster
    Post count: 2831

    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.

    #2100

    Nathan
    Participant
    Post count: 32

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

    #2103

    Tareq Hasan
    Keymaster
    Post count: 2831

    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]

    #2107

    Nathan
    Participant
    Post count: 32

    Awesome! That did the trick!

Viewing 15 posts - 1 through 15 (of 16 total)

The topic ‘Default Display Name’ is closed to new replies.