Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Created July 17, 2017 20:20
Show Gist options
  • Save rafaehlers/5752345e5351ef61d03af110c40b1005 to your computer and use it in GitHub Desktop.
Save rafaehlers/5752345e5351ef61d03af110c40b1005 to your computer and use it in GitHub Desktop.
Redirect users to a new URL after updating the entry.
<?php
add_action( 'gravityview/edit_entry/after_update', 'gravityview_redirect_after_update', 10, 2 );
function gravityview_redirect_after_update( $form, $entry_id ) {
// Get the current View ID
$view_id = GravityView_View::getInstance()->getViewId();
// Replace the 105 below to your specific View ID, otherwise, without this check all your Views will be affected
if($view_id == 105){?>
<script>
jQuery(document).ready( function() {
window.location.replace( "http://your-new-URL-here/" );
});
</script>
<?php
}else{
// Get the link to the View
$permalink_esc = esc_url( get_permalink( $view_id ) . '?updated=true' );
?>
<script>
jQuery(document).ready( function() {
window.location.replace( "<?php echo $permalink_esc; ?>" );
});
</script>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment