WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to create a template file and put there a login code, register code and widget code. I can do it for a widget, but I do not know how to do such thing for login and register. Any advice how to accomplish that?

share|improve this question
up vote 2 down vote accepted

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().

/* Template Name: (#56656) LoginLogoutEtc. */

dynamic_sidebar( 'sidebar_name' );

// Links to login/logout

// User is not logged in
if ( ! is_user_logged_in() )
    // Offer the login form
// Multisite: User may want to register
elseif ( is_multisite() AND ! is_user_member_of_blog() )

// In case the user wants to log out again
if ( is_user_logged_in() )
         '<a href="%s" title="Logout">Logout</a>'
share|improve this answer

You can use login and register forms as widgets also. Register more widget areas and use some plugins there. Just search for "wordpress login widget" and "wordpress registration widget".

Registration Widget
Sidebar Login

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.