Hi @cashwellcamc
I have tested this plugin with Gravity Forms by creating a form and inserting that from via http://prntscr.com/mz49lf this option and everything works fine from my end.
http://prntscr.com/mz49yg
Thanks!
Hi Sayan! Thanks for responding dude!
Yeah, it works when you initially add the form, or edit that shortcode…
But, if you update the form itself, without navigating to the ‘edit page view’ it doesn’t update. Here’s a screenshot.
Right now I’m suggesting the user just navigate to the page with the shortcode and ‘hit update’ there as well – after they edit the form via gravity forms or elsewhere.
I guess this might be looking into a hook or something with Gravity Forms?
Cheers,
-
This reply was modified 7 years, 2 months ago by
cashwellcamc.
-
This reply was modified 7 years, 2 months ago by
cashwellcamc.
-
This reply was modified 7 years, 2 months ago by
cashwellcamc.
-
This reply was modified 7 years, 2 months ago by
cashwellcamc.
Hi @cashwellcamc
Add this code to the end of your themes’s functions.php file:
add_action( 'gform_after_save_form', 'lmt_update_modified_info_on_form_update', 10, 2 );
function lmt_update_modified_info_on_form_update( $form, $is_new ) {
if ( $form['id'] == 1 ) { // change 1 with this id: http://prntscr.com/mzl1ju
$newdate = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
$args = array(
'ID' => 24, // change 24 with this: http://prntscr.com/mzl19u
'post_modified' => $newdate,
'post_modified_gmt' => get_gmt_from_date( $newdate ),
);
// Update the post into the database
wp_update_post( $args );
}
}
Hope this will do what you want. Thanks!
Ah, thanks so much! This does help, and seems to work – a shame there is no way to make it dynamic for multiple forms; but better then nothing I suppose. Thanks again for the help!
Hi @cashwellcamc
If you want to edit multiple form and upon editing automatically change the update date of multiple pages, you can use this code following:
add_action( 'gform_after_save_form', 'lmt_update_modified_info_on_form_update', 10, 2 );
function lmt_update_modified_info_on_form_update( $form, $is_new ) {
$newdate = date( 'Y-m-d H:i:s', current_time( 'timestamp', 0 ) );
$args = array(
'post_modified' => $newdate,
'post_modified_gmt' => get_gmt_from_date( $newdate ),
);
if ( $form['id'] == 1 ) { // change 1 with this id: http://prntscr.com/mzl1ju
$args['ID'] = 24;
} elseif ( $form['id'] == 2 ) {
$args['ID'] = 26;
}
if( isset( $args['ID'] ) ) {
// Update the post into the database
wp_update_post( $args );
}
}
Thanks!