Created
March 13, 2017 14:47
-
-
Save stompweb/9fc5aa9b40272b2560c4bda7055e9d81 to your computer and use it in GitHub Desktop.
Login rewrite
This file contains 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 | |
hm_add_rewrite_rule( | |
array( | |
'rewrite' => '^login/?$', | |
'template' => 'templates/login.php', | |
'query' => 'posts_per_page=1', | |
'title_callback' => function() { | |
return 'Login | ' . get_bloginfo( 'title' ); | |
}, | |
'post_query_properties' => array( 'is_home' => false, 'is_page' => false, 'login' => true ), | |
'request_callback' => function( WP $wp ) { | |
if ( is_user_logged_in() ) { | |
if ( en_is_group_leader() ) { | |
wp_redirect( get_bloginfo( 'url' ) . '/dashboard/' ); | |
} else { | |
wp_redirect( get_bloginfo( 'url' ) . '/courses/' ); | |
} | |
exit; | |
} | |
}, | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment