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 want to have a login username and password field in the header, and a registration link beside it. I want the registration link to go away once the user is logged in and the login fields to be replace with a logout link.

I have found these two snippets but they don't help me achieve what I want.

share|improve this question
You said "snippets", but didn't show any... – kaiser May 12 '11 at 0:35
up vote 2 down vote accepted
wp_login_form(); // Codex: http://codex.wordpress.org/Function_Reference/wp_login_form
// or:
wp_loginout(); // Codex: http://codex.wordpress.org/Function_Reference/wp_loginout
if ( ! is_user_logged_in() ) // Codex: http://codex.wordpress.org/Function_Reference/is_user_logged_in
    wp_register('', ''); // Codex: http://codex.wordpress.org/Function_Reference/wp_register
share|improve this answer
Thanks, however. that doesn't remove the login box after login, or provide a register link. – Keith Groben May 12 '11 at 0:55
Straight from the Codex wp_register() functions description: "This tag displays either the Site Admin link if the user is logged in or Register link if the user is not logged in." The if ( ! is_user_logged_in() ) can be wrapped around any of those three functions - also around the wp_login_form() function. So everything you asked for is in those 5 lines of the answer including links to the Codex and the according description. - Btw: As mentioned above: Please provide your "snipplets" including an explanation how and where you placed them. – kaiser May 12 '11 at 2:12

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.