Skip to content

Instantly share code, notes, and snippets.

@luistinygod
Last active April 14, 2022 01:37
Show Gist options
  • Save luistinygod/54f7f474dd295e89a8b8 to your computer and use it in GitHub Desktop.
Save luistinygod/54f7f474dd295e89a8b8 to your computer and use it in GitHub Desktop.
GravityView: redirect a user to a different location after updating an entry
<?php
/**
* Redirect the visitor to the single entry view after updating the entry
*/
function my_gv_redirect_after_update_to_single_entry_view( $form, $entry_id ) {
?>
<script>
jQuery(document).ready( function() {
window.location.replace( window.location.href.split('?')[0] );
});
</script>
<?php
}
add_action( 'gravityview/edit_entry/after_update', 'my_gv_redirect_after_update_to_single_entry_view',10, 2 );
/**
* Redirect the visitor to google.com after updating the entry
*/
function my_gv_redirect_after_update_to_external_page( $form, $entry_id ) {
?>
<script>
jQuery(document).ready( function() {
window.location.replace("http://www.google.com");
});
</script>
<?php
}
add_action( 'gravityview/edit_entry/after_update', 'my_gv_redirect_after_update_to_external_page',10, 2 );
@amuhareb
Copy link

this looks great. i know it's a bit old. but do you have any suggestions on how to make this work so that it only does this redirect when a certain selection is made in the updating process? I'd like to conditionally set whether this redirection happens, based on a user's selection

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