There’s wp_register()
which displays either a link to the registration or a login link.
Then you got wp_loginout()
that has either a login or logout link – depending on the login status of the user.
Another thing you could do is just adding a wp_login_form()
.
You can also use the plain wp_login_url( $redirect )
to construct a link yourself, where $redirect
would be the query args that you want to append. Then there’s also wp_logout_url()
to do the opposite.
To check if a user is logged in, just use is_user_logged_in()
.
<?php
/* Template Name: (#56656) LoginLogoutEtc. */
dynamic_sidebar( 'sidebar_name' );
// Links to login/logout
wp_loginout();
// User is not logged in
if ( ! is_user_logged_in() )
{
// Offer the login form
wp_login_form();
}
// Multisite: User may want to register
elseif ( is_multisite() AND ! is_user_member_of_blog() )
{
wp_register();
}
// In case the user wants to log out again
if ( is_user_logged_in() )
{
printf(
'<a href="https://wordpress.stackexchange.com/questions/56656/%s" title="Logout">Logout</a>'
,wp_logout_url();
);
}