How to save two values for a single response in registration form?

I have a form for site registration that includes users choosing who their coach is from a dropdown list. The values are the email addresses of the coaches, and those get added to the user meta table. I want to also be able to save the coach names (as separate user meta entries), without requiring the user to answer the “who is your coach?” question twice.

Is there a way to have a hidden field that will dynamically get the value of the coach name (which is already there as the name for the “who is your coach” field)? Or is there some other way to do this?

Note: We have a limited and known set of coaches, so if the only way to do it is to create an action or something that gets triggered on registration to do an “if coach email is x, then coach name is y and add to user meta with key coach_name” I’m open to that if it’s the only (or best) way to achieve this (if someone can help me figure out how to do it).


So, the “Who is your coach?” question shows the name as the label, and the value is the email address? Or is it working in some other way? Are both the coach’s name and email present in the form when the user makes their selection? Do you have the form online somewhere where we can see it?

Yes, the coach name is the label, and the value is the email.

You can see the form here:

I’ve got the coach email being saved successfully to the user meta with key ‘trimergence_consultant’ and now I realize we could make use of having the coach name available also (would need to have a separate key).

In that case (the name is already in the form when it is submitted) you can use the gform_user_registered filter:

That example shows using a value from the submission to update a meta key for the registered user. You would need to adjust the meta key, and the field ID to write to the usermeta.

Thanks Chris… I think I’m part way there…

I’ve added this:

add_action( 'gform_user_registered', 'add_custom_user_meta', 10, 4 );
function add_custom_user_meta( $user_id, $feed, $entry, $user_pass ) {
update_user_meta( $user_id, 'trimergence_consultant_name', rgar( $entry, '19' ) );

…but it got me the value of the coach field rather than the name/label added to the user meta.