WordPress.org

Ready to get started?Download WordPress

Forums

Adding a login/register box to a page (9 posts)

  1. interlude22
    Member
    Posted 7 years ago #

    Hello, I have a static front page on my wordpress site set up as a page, i want visitors to be encouraged into registering - is it possible to insert the log-in/register box into a page within wordpress.

    any responces are appreciated
    cheers

  2. Christopher J. Hradil
    Member
    Posted 7 years ago #

    if you want to add a login box somewhere, you'll just need to paste:

    <form name="loginform" id="loginform" action="wp-login.php" method="post">
    <p><label><?php _e('Username:') ?><br /><input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1); ?>" size="20" tabindex="1" /></label></p>
    <p><label><?php _e('Password:') ?><br /> <input type="password" name="pwd" id="pwd" value="" size="20" tabindex="2" /></label></p>
    <p>
    <label><input name="rememberme" type="checkbox" id="rememberme" value="forever" tabindex="3" />
    <?php _e('Remember me'); ?></label></p>
    <p class="submit">
    <input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="4" />
    <input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?>" />
    </p>
    </form>

    where you want the login box, I would create a custom "div" class in my css and put the form in a <div> with that class, and to style it to my liking.

    if you want to "encourage registration" and put registration boxes where ever you'd like to you just need to paste :
    <form method="post" action="wp-register.php" id="registerform">
    <p><input type="hidden" name="action" value="register" />
    <label for="user_login"><?php _e('Username:') ?></label><br /> <input type="text" name="user_login" id="user_login" size="20" maxlength="20" value="<?php echo wp_specialchars($user_login); ?>" /><br /></p>
    <p><label for="user_email"><?php _e('E-mail:') ?></label><br /> <input type="text" name="user_email" id="user_email" size="25" maxlength="100" value="<?php echo wp_specialchars($user_email); ?>" /></p>
    <p><?php _e('A password will be emailed to you.') ?></p>
    <p class="submit"><input type="submit" value="<?php _e('Register') ?> &raquo;" id="submit" name="submit" /></p>
    </form>

    where you'd like the registration form to appear, ditto the <div> info above.

  3. Christopher J. Hradil
    Member
    Posted 7 years ago #

    one other thing, i'd incorporate this link under the form:
    <a href="<?php bloginfo('wpurl'); ?>/wp-login.php"><?php _e('Login') ?></a>

    if i were using the registration form.

    and this link:
    <a href="<?php bloginfo('wpurl'); ?>/wp-register.php"><?php _e('Register') ?></a>

    under the form if I were using the login form.

  4. interlude22
    Member
    Posted 7 years ago #

    cheers for the feedback, i have tried the dummy method of literaly copy & paste into the html editor on my home page (i have set up a 'home' page out of the loop taht i want to put the reg box in) and i get two boxes and a button appear, however part of the code is in the boxes and buttons and does not produce a working result. My php know how is something of little to none, could you give me any more advice on how formating works? Do i have to mannually find the page within my database and enter the code in that way, or this code to enter into say a sidebar.php or header.php file. cheers

  5. Christopher J. Hradil
    Member
    Posted 7 years ago #

    you've got a couple of options,

    - if you create a "page" using the dashboard under "write->page" you can place the code in there (don't use the "fancy text" editor though), I would create my own css classes for the form's styling and put those in my theme's style.css file.

    - if you just want to "permanantly" add one of those forms to say all "single post" pages, then just paste the form into single.php for your theme where you want the form, ditto css info.

    - same idea for sidebar.php

    it really depends on where/when you want the forms to appear as far as where/how to use the form code.

    i was thinking you might have just created some static html pages of your own which might not work as easily as creating a "page" through the WP admin interface.

  6. hjabb
    Member
    Posted 7 years ago #

    I tried this and no go.. did I do something wrong? It doesn't work at all in a page.. but it does show up right in the sidebar. But when you click the button to register it goes to the main page... is there something in the wp-register.php I'm missing?

    thanks!

  7. hjabb
    Member
    Posted 7 years ago #

    I tried this and no go.. did I do something wrong? It doesn't work at all in a page.. but it does show up right in the sidebar. But when you click the button to register it goes to the main page... is there something in the wp-register.php I'm missing?

    thanks!

  8. hjabb
    Member
    Posted 7 years ago #

    I tried this and no go.. did I do something wrong? It doesn't work at all in a page.. but it does show up right in the sidebar. But when you click the button to register it goes to the main page... is there something in the wp-register.php I'm missing?

    thanks!

  9. Shriekman
    Member
    Posted 6 years ago #

    Hi chradil -

    I went ahead and tried your fixes -- first, I tried the Login code -- it did work in the sense that it logged you into the system, but it dropped me on the wp-login.php page with it blank. I had to manually get back to the front page and there I could see I was logged in.

    So then I tried the registration aspect, and that just dropped me on the wp-login.php?action=register page so it actually didn't work at all.

    I really, really love the idea of being able to register/login from the front page (or elsewhere on the site) and am surprised it's so difficult -- I could probably tweak the code for the login to redirect back to the front page, but the register box seems to be more what I need.

    Any help from anyone is appreciated!

    Greg

Topic Closed

This topic has been closed to new replies.

About this Topic