Skip to content

Instantly share code, notes, and snippets.

@rafaehlers
Created August 15, 2017 14:03
Show Gist options
  • Save rafaehlers/7a709f2f24c4f12266a385dbd24417e3 to your computer and use it in GitHub Desktop.
Save rafaehlers/7a709f2f24c4f12266a385dbd24417e3 to your computer and use it in GitHub Desktop.
Redirect to diferent Views after entry update
<?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();
if ( $view_id == 105 ) {?>
<script>
jQuery(document).ready( function() {
window.location.replace( "http://localhost/gravity/" );
});
</script>
<?php
}elseif ( $view_id == 212 ){?>
<script>
jQuery(document).ready( function() {
window.location.replace( "http://localhost/gravity/" );
});
</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