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.

  • You said "snippets", but didn't show any... – kaiser May 12 '11 at 0:35
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
| 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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