Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Forked from dancameron/functions.php
Last active August 29, 2015 14:14
Show Gist options
  • Save mauriciogofas/3b9bbdcd3fb6ac718802 to your computer and use it in GitHub Desktop.
Save mauriciogofas/3b9bbdcd3fb6ac718802 to your computer and use it in GitHub Desktop.
Redirect Away if not logged in and redirect back
<?php
function si_redirect_if_not_logged_in() {
$url = get_permalink( $invoice_id );
if ( !is_user_logged_in() ) {
wp_redirect( home_url() . '/login/?redirect_to=' . $url . '&reauth=1');
exit();
}
}
//
add_action( 'pre_si_invoice_view', 'si_redirect_if_not_logged_in' );
add_action( 'pre_si_estimate_view', 'si_redirect_if_not_logged_in' );
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment