I have this code from GravityEdit that triggers & updates whoever edited a Gravity Form with the user name.
As per their documentation I can currently place one form.(i.e form name & form ID)
`add_filter( 'gravityview-inline-edit/entry-updated', 'gravityedit_custom_who_changed', 10, 5 );
function gravityedit_custom_who_changed( $update_result, $entry = array(), $form_id = 0, $gf_field = null, $original_entry = array() ) {
if ( 124 !== (int) $form_id ) { // replace 124 with your form ID
return $update_result;
}
$current_user = wp_get_current_user();
if ( ! ( $current_user instanceof WP_User ) ) {
return $update_result;
}
$field_id = 3; // replace 3 with the ID of the field you want to store the username
$update_result = GFAPI::update_entry_field( $entry['id'], $field_id, $current_user->user_login );
return $update_result;
}`
Can anyone assist on how I can add a second form i.e another form & ID (e.g form 25 form id 3)?
(I'm in Marketing R&D pardon my noobness in PHP)
Thanks!
Getting "cannot redeclare" when I duplicate the code in functions.php
In an "if" statement, you can use || for the logical operator "or":
'if ( 124 !== (int) $form_id )' can be changed to: