Skip to content

Instantly share code, notes, and snippets.

@stompweb
Created March 13, 2017 14:47
Show Gist options
  • Save stompweb/9fc5aa9b40272b2560c4bda7055e9d81 to your computer and use it in GitHub Desktop.
Save stompweb/9fc5aa9b40272b2560c4bda7055e9d81 to your computer and use it in GitHub Desktop.
Login rewrite
<?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