V
V
vadbobkov2018-10-24 10:07:54
WordPress
vadbobkov, 2018-10-24 10:07:54

How to set up a login panel in Wordpress with the output of the required page?

Good afternoon. How can I implement this function in wordpress.
When you first visit the WORDPRESS site, a login form should appear on the site, let's say wp-login. Further, when the user entered the login and password, he gets to the main page of the index.php template.
This method must be done until the session of the user's stay in the account ends. If the session has expired, then it is redirected back to wp-login for login.
Is it realistic to do it? If so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sobolev, 2018-10-24
@san_jorich

What is the difficulty? This mechanism is already implemented in WP, it remains to add a redirect

if ( is_user_logged_in() ) {
  wp_redirect( home_url() );
}

Or so
function my_login_redirect( $url, $request, $user ){
if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
if( $user->has_cap( 'administrator') or $user->has_cap( 'author')) { $url = admin_url(); } 
else { wp_redirect( home_url() ); }
}
}
add_filter('login_redirect', 'my_login_redirect', 10, 3 );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question