Created
August 15, 2017 14:03
-
-
Save rafaehlers/7a709f2f24c4f12266a385dbd24417e3 to your computer and use it in GitHub Desktop.
Redirect to diferent Views after entry update
This file contains hidden or 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 | |
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