PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Adding Additional User Meta Fields

  1. Loving the new site, and 1.5 (although i have been using the 1.5Beta for some time)
    I'm just wondering about manually adding new user Meta Fields/Info that has been taken from a New User Registration form?

    As an example, in the Registration form I a Company Name: field, I have created the "User Meta" in the User Registration settings. I would now like to display this info.

    Useing Justin Tadlock's "Adding and using custom user profile fields" (http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields) code

    add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
    add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
    
    function my_show_extra_profile_fields( $user ) { ?>
    
    	<h3>Extra profile information</h3>
    
    	<table class="form-table">
    
    		<tr>
    			<th><label for="twitter">Twitter</label></th>
    
    			<td>
    				<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
    				<span class="description">Please enter your Twitter username.</span>
    			</td>
    		</tr>
    
    	</table>
    <?php }

    I can add entry fields, but how would I populate the field with the registered users Meta?

    Can anyone help? Have I been clear enough?

    Thanks

    Posted 10 years ago on Thursday March 24, 2011 | Permalink
  2. Hi Aspect,

    The user meta added by the User Registration Add-on is populate in the same wp_usermeta table as the standard WP user meta and is accessible by the same function used in Justin's tutorial.

    [php]
    get_the_author_meta('team_name', $user->ID)

    Just update the 'team_name' to whatever your custom meta name is.

    Posted 10 years ago on Thursday March 24, 2011 | Permalink
  3. I'm utilizing these techniques as well, but no luck. I have had over 140 people register through my site and just realized that the custom meta data is not being attached to the user. For example I have a user meta field called 'weight' so in the user registration add-on I created an 'Add Custom' field and called it 'weight' then selected the form field I wanted to populate it with.

    From what I can tell this is the proper method. I also know that when a user goes to their profile and puts the information in there it saves it perfectly fine. So I know with Gravity Forms not being in the picture the custom user meta is functioning as designed and as intended. However, the registration for I have that allows users to put that information in at the beginning is not functioning to get me that information into their profiles.

    Any ideas?

    Posted 10 years ago on Friday May 20, 2011 | Permalink
  4. The functionality works as intended so any issues are going to be either with how you configured the user registration add-on fields, or how your code is implemented to display the custom field value.

    You would have to test by filling out a registration form, creating a user, and then look in your database tables using something like PHPMyAdmin to look in the user meta database tables to see if the data you just existed is created. That will tell you if the data is actually in the database or not to determine if there is something wrong with the data collection or not.

    Posted 10 years ago on Friday May 20, 2011 | Permalink
  5. dgomez
    Member

    Where is the field name value (custom meta name ) set when creating a registration form using GF?

    get_the_author_meta('team_name', $user->ID)

    In this example where do I set team_name to match with the code I'm adding in my function.php file.

    Posted 10 years ago on Friday August 5, 2011 | Permalink
  6. @dgomez that is set on the User Registration menu item, under Forms. This is where you edit your user registration feed.

    http://www.example.com/wp-admin/admin.php?page=gf_user_registration

    Once you click "edit" for your registration feed (there may only be one) you will see a screen that looks something like this:

    http://minus.com/mboO2hL

    You set your "team_name" (which is the meta key) under the section "User Meta". In your case the left side will be "team_name" and the right side will be mapped to the field that you where you are setting the team name.

    In my case, the first meta key is "email_users_accept_notifications" and the form field is "Accept to receive post or page notification emails" (and in my form, I used a value of "true" since that is what I want the meta value to be set to when the user checks that box on my registration form.

    If you need more help setting it up, please let us know.

    Posted 10 years ago on Saturday August 6, 2011 | Permalink