Created
July 17, 2017 20:20
-
-
Save rafaehlers/5752345e5351ef61d03af110c40b1005 to your computer and use it in GitHub Desktop.
Redirect users to a new URL after updating the entry.
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(); | |
// 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