Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Created June 11, 2018 20:51
Show Gist options
  • Save rafaehlers/bcf544f0a6731b3ac0a43fd85b69e0a1 to your computer and use it in GitHub Desktop.
Save rafaehlers/bcf544f0a6731b3ac0a43fd85b69e0a1 to your computer and use it in GitHub Desktop.
Update the entry creator based on a dropdown field generated by this sample: https://gist.github.com/joshuadavidnelson/b9624760a81c2c35f6b5#file-populate-user-email-drop-down-php
<?php
add_action('gform_after_update_entry_115', 'gv_change_entry_creator', 10, 2);
function gv_change_entry_creator( $form, $entry_id ){
$entry = GFAPI::get_entry($entry_id);
$new_entry_creator = $entry[1]; // field ID where the dropdown with usernames are (this will be the new entry creator)
GFAPI::update_entry_property( $entry_id, 'created_by', $new_entry_creator );
}
@rafaehlers
Copy link
Author

rafaehlers commented Jun 11, 2018

Make sure to replace "115" on the filter name for the FORM ID. If FORM ID is 16 for example, then the hook will be:

add_action('gform_after_update_entry_16', 'gv_change_entry_creator', 10, 2);

Sample form

gv-test-form

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment