Skip to content

Instantly share code, notes, and snippets.

@mikeschinkel
Created May 30, 2013 01:00
Show Gist options
  • Save mikeschinkel/5675096 to your computer and use it in GitHub Desktop.
Save mikeschinkel/5675096 to your computer and use it in GitHub Desktop.
Example class showing how to redirect to a custom login page.
class Mysite_Auth {
function __construct() {
add_filter( 'login_redirect', array( $this, 'login_redirect' ) );
}
function login_redirect( $redirect_url ) {
if ( is_user_logged_in() ) {
wp_safe_redirect( '/custom-login' );
exit;
}
return $redirect_url;
}
/**
* These might be useful hooks
*/
// function login_headerurl( $header_url ) {
// return $header_url;
// }
// function login_headertitle( $header_title ) {
// return $header_title;
// }
// function login_message( $message ) {
// return $message;
// }
// function registration_redirect( $redirect_url ) {
// return $redirect_url;
// }
// function lostpassword_redirect( $redirect_url ) {
// return $redirect_url;
// }
// function admin_url( $url, $path, $blog_id ) {
// }
//
// function login_enqueue_scripts() {
//
// }
// function login_head() {
//
// }
// function login_errors( $errors ) {
// return $errors;
// }
// function login_messages( $messages ) {
// return $messages;
// }
}
new Mysite_Auth;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment