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.

log in & values saved for each user

  1. I'm sure this would have to be done in conjunction with other programing/plugins, but I'm wanting to have users log into my site to fill out a data collection form annually. I'd like for their answers from last year to automatically populate when they log in and they can go in at any time and update their answers.

    Has anyone had any success doing something like this? what is the best way to approach this?

    Thanks!

    Matt

    Posted 12 years ago on Sunday June 19, 2011 | Permalink
  2. Hi Matt,

    This could be accomplished using the gform_post_submission and referencing this post for populating fields from the user meta. Be aware, that this will require some basic understanding of PHP and being comfortable with some WP functions.

    When the form is submitted, you would update a group of user meta fields you designate to store the submitted values from the form. This is accomplished with the gform_post_submission hook. This hook is passed all of the submitted value in the $entry object. You would match the field ID of each field with it's respective user meta field. For example, if field ID 2 is supposed to store the user's secondary email address (just an example piece of data you may be storing) you could save that value to the user meta like so:

    [php]
    update_user_meta($user_id, 'secondary_email', $entry[2]);

    For more information on the update_user_meta function, read here.

    That part covers how to save the values consistently for each user. To pre-populate any piece of user meta, refer to the post linked in the first paragraph above.

    Posted 12 years ago on Sunday June 19, 2011 | Permalink
  3. hmm...I'm pretty sure this is over my head...anyone for hire?

    Posted 12 years ago on Tuesday June 21, 2011 | Permalink
  4. Here is a list of WordPress developers with Gravity Forms experience:

    http://wpcandy.com/pros/experienced/with-gravity-forms

    Don't be scared off by the project prices on that page, those are typically for full web sites and not smaller projects or customization work.

    Posted 12 years ago on Tuesday June 21, 2011 | Permalink
  5. Lee Hord
    Member

    I thought I'd post this as I've seen many posts on the forum about this very subject. I too had a similar requirement and this is how I solved it. May not be the most elegant piece of code ever written but it certainly does the job.

    add_action("gform_post_submission_87", "my_update_user_meta", 10, 2);
    function my_update_user_meta( $entry, $form ) {
    	global $current_user;
    		   get_currentuserinfo();
    		   $user_id = $current_user->ID;
    
    	update_user_meta($user_id, 'ouc', $entry[15]);
    
    }

    Obviously you would need to change form and entry id's to suit.

    Posted 12 years ago on Wednesday July 6, 2011 | Permalink