Last active
April 14, 2022 01:37
-
-
Save luistinygod/54f7f474dd295e89a8b8 to your computer and use it in GitHub Desktop.
GravityView: redirect a user to a different location after updating an entry
This file contains 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 | |
/** | |
* 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 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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