Created
June 11, 2018 20:51
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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