• I posted this a year ago, was marked as “resolved”, but the plugin continues with this problem:

    1. If “First Name” and “Last Name” fields are filled:
    The plugin will set the User field “display_name” to their “first name + last name”. (GREAT!)

    2. If both “First Name” and “Last Name” fields are empty:
    Display_name will be set to the username. (OBVIUS)

    3. If “Last Name” is filled, but “First Name” is empty:
    Display_name will be set to the “Last Name”. (AS EXPECTED)

    BUT…

    4. If “First Name” is filled, but “Last Name” is empty:
    Display_name will be set to the username
    . (NOT THE EXPECTED BEHAVIOUR)

    The expected behaviour would be that in case only “First Name” is filled (and “Last Name” is empty), display_name should be set to the “Firt Name”, isnt it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @sukinoz ,

    I’m sorry this is not working as expected. I’ve just read your previous support ticket, and sorry the question was misunderstood.

    This is how the plugin should work by default; if one or both of these fields are empty, the display_name will be set to their username.

    if ( empty( $first_name ) || empty( $last_name ) ) {
    		return;
    	}

    I’m not sure why you are getting a Last Name to show, might there be any custom code or plugins that are allowing the Last Name to appear on its own.

    This can be change to work for your need with custom development. You would need to remove_action these lines?https://github.com/strangerstudios/force-first-last/blob/42637726772f2a6023f380c356510ca6bbc6ed66/force-first-last.php#L98-L100

    Then create your own function without the empty check on the last name?https://github.com/strangerstudios/force-first-last/blob/42637726772f2a6023f380c356510ca6bbc6ed66/force-first-last.php#L33

    And re-add the filters that were removed with the new function.

    Kim W

    Thread Starter Suki

    (@sukinoz)

    Thank you very much for your response.

    I understand that the plugin works like this.

    But what I want to say here is that for me the expected behaviour is that if “first name” or “last name” are empty, the expected result would be “firt name + empty value” or “empty value + last name”.

    That is to say, I don’t think that the requirement that both fields must be filled-in for the plugin to work, is presumed a priori by the users.

    It is more a usability issue than a technical one.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘If only “First Name” is filled, it is not used as Display Name’ is closed to new replies.