<![CDATA[ Fullname vs. First and Last - MODX Community Forums]]> https://forums.modx.com/thread/?thread=103706 <![CDATA[Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557831
On my registration form I chose to disable the default "fullname" field and replace it with "first" and "last" name fields instead. It works fine.

With regard to managing users from the Manager the "fullname" field is obviously quite useful so I'm wondering if there's a way to grab and combine the "first" and "last" name values from the Registration form and use them as the value for the "fullname" field.

I realize I could display the "first" and "last" names as extended fields on the user Manager page but if possible I would prefer to make use of the "fullname" field since it's already there.]]>
todd.b Apr 06, 2018, 05:41 PM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557831
<![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557900 todd.b Apr 10, 2018, 08:13 PM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557900 <![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557891
Could you post the code for your update profile page?

It should start with

It should also contain this somewhere

andytough Apr 10, 2018, 01:09 PM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557891
<![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557880

I agree that there should be firstname and lastname fields. I think almost everyone who uses MODX would agree. wink]]>
BobRay Apr 10, 2018, 05:08 AM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557880
<![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557875
Out of curiosity how could they be extracted with a snippet?

The entire reason for using "firstName" and "lastName" is to ensure people actually enter two names. The "fullname" field is too easy to dismiss.

Honestly, I find it quite strange MODX doesn't default to "first" and "last" instead of fullname. If it did it would make all of this hoop-jumping entirely unnecessary. Maybe in MODX 3.0.]]>
todd.b Apr 09, 2018, 09:19 PM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557875
<![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557872
A simpler option would be to just use the fullname (no first of last input) after the user has registered and let the user update that. You could extract the first and last names with a snippet whenever you needed it. Since you got them separately in Register, you don't have to worry about middle names and the like.

You could also use ClassExtender to add those new fields, but that seems like overkill for the use case.]]>
BobRay Apr 09, 2018, 08:38 PM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557872
<![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557852
I think it makes sense. It is related to the sequence of events. The new firstname and lastname have not been submitted when the prehook fetches them. On my site it appears that if you update the profile twice it puts the new firstname or lastname into fullname.

Would making the prehook a posthook work?

I not I think it might be necessary to use Javascript to capture the new firstname or lastname field contents.

There are a couple of conversations about this.

I can't look into it right now, but will do so later, as I need to sort it on my own site!]]>
andytough Apr 09, 2018, 09:59 AM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557852
<![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557842
Your solution works perfectly with the Register snippet but I just noticed that when using the UpdateProfile snippet to uh... update the user profile from the front-end, that editing either the "first" or "last" name fields does not update the "fullname" field on the Manager > Users page.

I added the &preHooks property and hidden text field to the UpdateProfile form but it doesn't seem to have any effect.]]>
todd.b Apr 08, 2018, 12:22 AM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557842
<![CDATA[Re: Fullname vs. First and Last]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557836
That's fantastic, thank you very much.]]>
todd.b Apr 06, 2018, 10:32 PM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557836
<![CDATA[Re: Fullname vs. First and Last (Best Answer)]]> https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557835
This code has worked for me.

Add a prehook to the registration form

The fullname snippet code
$fullname = $hook->getValue('firstName').' '.$hook->getValue('lastName');
return true;

In the html
<input type="hidden" name="fullname" id="fullname" value="[[!+firstName]] [[!+lastName]]" />

andytough Apr 06, 2018, 09:53 PM https://forums.modx.com/thread/103706/fullname-vs-first-and-last#dis-post-557835