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.

Set the lead "created_by" field to newly created user

  1. I have created a plugin that allows users to edit their entries since it is not available through gravity forms yet. It relies on the "created_by" field to display the entries back to the user, I am also using the "User Registration" plugin to create a new user if not logged in. Is there an easy way to set the "created_by" field to the newly created user?

    Posted 11 years ago on Tuesday June 11, 2013 | Permalink
  2. Got it.

    add_action('gform_user_registered', 'gfee_update_created_by', 10, 4);
    function gfee_update_created_by($user_id, $config, $lead, $user_pass) {
    	global $wpdb;
    	$lead_table = RGFormsModel::get_lead_table_name();
    	$lead_id = $lead['id'];
    	$wpdb->query($wpdb->prepare("UPDATE $lead_table SET created_by=$user_id WHERE id=$lead_id"));
    
    }
    Posted 11 years ago on Tuesday June 11, 2013 | Permalink