I am trying to make a user registration form in my site's side bar. Users are able to register but instead of getting a success message, WordPress usually redirect them to 404 page.

Below is my form:

<form id="joinmaillist"   method='post'>
            <td><input type="text" placeholder="Your name here.." name="name" title="Please enter your name" required/></td>
            <td><input type="email" name="email" placeholder="Your email here.." required/></td>
            <td style="text-align:right"><input class="submitmail" type="submit" value="Join!" name="joinm"/></td>

and below is my PHP code:

if (isset($_POST['joinm'])){
    $email =$_POST['email'];

$user_id=  username_exists($user_name);

    if (!$user_id){
        $random_pass = wp_generate_password(12, false);
        $user_id=wp_create_user($user_name, $password, $email);
        header('Location:' . $_SERVER['REQUEST_URI']);


1 Answer 1


Look at the code in wp-login.php (line 481 and following). There you can see how registration works.

The names of your form – email, name – are probably overwritten by WordPress. Always use prefixed names in forms to avoid collisions, eg.: ma_email and ma_name.

Prepare incoming data. Do not just write anything someone sends you into your data base. It may be dangerous.

Oh, and welcome to WordPress Stack Exchange! :)

  • Thanks I thought wordpress had already prepare all our inputs. So I think i should not worry but now I will be careful Commented Mar 8, 2012 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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