0

i'm customzing my admin bar/tool bar and i've added login/logout/lostpassword. but when it comes to the registrations form i've met a brick wall

function registration_admin_bar() {
    global $wp_admin_bar;

    $wp_admin_bar->add_menu( array(
        'id' => 'registration-admin-bar',
        'parent' => 'top-secondary',
        'title' => '


            <form id="registration_form" class="registration_form" action="" method="POST">
            <fieldset>
                <p>
                    <label for="user_Login_name">Brugernavn</label>
                    <input name="user_login_name" id="user_login_name" class="required"  type="text"/>
                </p>
                <p>
                    <label for="user_first_name">Fornavn</label>
                    <input name="user_first_name" id="user_first_name" class="required"  type="text"/>
                </p>
                <p>
                    <label for="user_last_name">Efternavn</label>
                    <input name="user_last_name" id="user_last_name" class="required" type="text"/>
                </p>
                <p>
                    <label for="user_email">Email</label>
                    <input name="user_email" id="user_email" class="required"  type="email"/>
                </p>
                <p>
                    <label for="user_vognl">Vognløbs nr.</label>
                    <input name="user_vognl" id="user_vognl"  type="text"/>
                </p>                
                <p>
                    <label for="user_phone">Telefon nr.</label>
                    <input name="user_phone" id="user_phone"  type="text"/>
                </p>                
                <p>
                    <label for="password">Kode</label>
                    <input name="user_pass" id="password" class="required" type="password"/>
                </p>
                <p>
                    <label for="password_again">Gentag Kode</label>
                    <input name="user_pass_confirm" id="password_again" class="required" type="password"/>
                </p>
                <p>
                    <input type="hidden" name="register_nonce"   />
                    <input type="submit" value="Register din bruger"/>
                </p>



       '
    ) );
}
add_action( 'admin_bar_menu', 'registration_admin_bar' ); 

as shown above i've created the registration form and it works but i can't use php code which limits me to only this basic form normaly i would write $_POST['user_login_name'] as value in the input user_login_name so people dont have to start over if they type the passwords wrong or something.

dos anyone have a creative idea to get around this?

//Alexander

  • Why can't you use PHP? – Digital Brent May 10 '15 at 15:27
  • it crashes the site if i supply my html form with any kind of php code – Alexander May 10 '15 at 15:30
  • either that or it just displays the entire php code – Alexander May 10 '15 at 15:45
0

One option you have is to use JS to create cookies that store the entered information. Here is an article that explains how to do this. The cookies will last even if a form fails to submit. Just make sure you delete the cookies after you use them. I believe it is a security risk if you make cookies and just leave them. My experience with cookies is limited so I'd say just try the article and it should work. This also allows you to avoid your php problem, though to be honest, I'd look more into that and try to figure out why the php is making your site crash. It's definitely not supposed to do that.

0

This ended up being my answer!

first i let $form_register = a function containing the form i need with php included in it. then i make a new menu entry in the toolbar and let $form_register be the titel, so now it can keep the values if the user enter something incorrectly so they dont have to start all over again :).

hope this helps someone meeting the same problem as me :D

    function admin_bar_registration_menu( $wp_admin_bar ) {
        if(!is_user_logged_in()) {
    if ( get_option( 'users_can_register' ) ) {
    $form_register = registration_form_fields(
    );
        $wp_admin_bar->add_menu( array(
        'id'     => 'register',
        'title'  => $form_register,
    ) );
}}
}
add_action( 'admin_bar_menu', 'admin_bar_registration_menu' );
  • Nice. Glad you found out what was wrong and were able to fix it. – Digital Brent Jul 28 '16 at 0:58

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.