I have a frontend login system.
What I want to achieve is -
If users log in at the front page, it will remains at the same page, if admin log in, it will redirect to /wp-admin/
dashboard.
This is my front page login codes.
<?php if( is_user_logged_in() ) { ?>
<?php
/*
Template Name: front page
*/
get_header();
global $user_identity;
$redirect = $_SERVER['REQUEST_URI'];
?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; // end of the loop. ?>
<?php } else { ?>
<form action="<?php echo get_option('home'); ?>/wp-login.php" method="post" id="main_comment_form" class="comments-form">
<h2>Login</h2>
<div class="row">
<label for="username">Username</label><br />
<input type="text" class="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" required/>
</div>
<div class="row">
<label for="password">Password</label><br />
<input type="password" class="text" name="pwd" id="pwd" required/>
</div>
<span class="submit"><input type="submit" value=" Login " name="submit"></span>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>" />
</form>
<?php
}
?>