Populating fields on a page from a user registration form

Hello All,
I’ve looked around for solutions what I’m trying to achieve and it’s time I bring it to the help forums for ideas.

So, here’s the scenario. A user accesses the site and is greeted with a registration form. The fields are username, email, date of birth and password. All of those are default fields, so nothing special there. The user registers and can now access the site.

Here’s where I’m running into problems…

I have a page set up with a form on it that I need to have populated with data, based on the user that is logged in, when the page is accessed. We’ll say the fields are username, email, and date of birth. Now, you can use the default merge tags for the first two. What I cannot figure out is how to populate the date field with that user’s date of birth that was collected from the registration form.

I’ve tried to create custom merge tags with little or no success. I will admit I am just firing shots in the dark at this point. It’s either ridiculously simple and right under my nose or it’s going to be a lot of custom code, which is fine.

Given that all of the data is there, I can’t imagine this not being possible. So, there we have it.

Does anyone have any suggestions? I appreciate any help. :slight_smile:

Have you messed with the User Registration App? It should have options for that. Otherwise you need to do some coding. I have similar, but for billing fields:

add_filter('gform_field_value_user_baddress1', 'gform_populate_user_baddress1');
function gform_populate_user_baddress1($value){

  	$user_id = get_current_user_id();
	$user_data = get_userdata($user_id);
  	$capabilities = wp_capabilities;
	$get_role = get_user_meta( $user_id, $capabilities, true );
	$user_role = key($get_role);
	  	if ($user_role == 'company'){
		   $key = 'billing_address_1'; 
		   $single = true;
		   $value = get_user_meta( $user_id, $key, $single );
		   return $value; 
  		}
 }

To update this when changed I use gform_after_submission and:

$meta_key_address1 = rgar( $entry, '4.1' );

update_user_meta( $user_id, billing_address_1, $meta_key_address1 );

Hope that’s what you need!

Hi there, I will give that a look over but it does appear to a step in the right direction at a glance. I assume there’ll be some added code but that’s not a problem. I appreciate the suggestion and I’ll report back as soon as I can test some things out. Thanks!