Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:31:56+00:00 2026-05-29T06:31:56+00:00

I have a custom registration form. I am trying to redirect users to a

  • 0

I have a custom registration form. I am trying to redirect users to a specific page after they’ve registered, but the methods I have tried have not worked, here is my code – how can I get a redirection after a user has registered?:

EDIT: (a jQuery or Javascript solutuion for this would be acceptable too)

<?php
/* Load registration file. */
require_once( ABSPATH . WPINC . '/registration.php' );

/* If user registered, input info. */
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'adduser' ) {
    $user_pass = wp_generate_password();
    $userdata = array(
        'user_pass' => esc_attr( $_POST['user_pass'] ),
        'user_login' => esc_attr( $_POST['user_name'] ),
        'user_email' => esc_attr( $_POST['email'] ),
    );

    if ( !$userdata['user_login'] )
        $error = __('A username is required for registration.', 'frontendprofile');
    elseif ( username_exists($userdata['user_login']) )
        $error = __('Sorry, that username already exists!', 'frontendprofile');
    elseif ( !is_email($userdata['user_email'], true) )
        $error = __('You must enter a valid email address.', 'frontendprofile');
    elseif ( email_exists($userdata['user_email']) )
        $error = __('Sorry, that email address is already used!', 'frontendprofile');

    else{
        $new_user = wp_insert_user( $userdata );
        update_usermeta( $new_user, 'fullname', esc_attr( $_POST['fullname']  ) );
        update_usermeta( $new_user, 'publication', esc_attr( $_POST['publication']  ) );
        update_usermeta( $new_user, 'usertype', esc_attr( $_POST['usertype']  ) );
        wp_new_user_notification($new_user, $user_pass);
        wp_redirect( 'http://www.google.com' );
    }
}

?>

<form method="post" id="adduser" class="user-forms" action="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">
  <p class="form-usertype">
  <strong>TYPE</strong>
    <?php $usertype = get_the_author_meta( 'usertype', $current_user->ID ); ?>
  <ul>
    <li>
      <input class="radio" value="Media" name="usertype" <?php if ($_POST['usertype'] == 'Media' ) { ?>checked="checked"<?php }?> type="radio" />
      <span><?php _e('Media', 'frontendprofile'); ?></span>
    </li>
    <li>
      <input class="radio" value="Freelance"  name="usertype" <?php if ($_POST['usertype'] == 'Freelance'  ) { ?>checked="checked"<?php }?> type="radio" />
      <span><?php _e('Freelance',  'frontendprofile'); ?></span>
    </li>
    <li>
      <input class="radio" value="Student" name="usertype" <?php if ($_POST['usertype'] == 'Student' ) { ?>checked="checked"<?php }?> type="radio" />
      <span><?php _e('Student', 'frontendprofile'); ?></span>
    </li>
  </ul>
  </p>
  <!-- .form-usertype -->

  <p class="form-username">
    <strong>FULL NAME</strong>
    <input class="text-input" name="user_name" type="text" id="user_name" value="<?php if ( $error ) echo wp_specialchars( $_POST['user_name'], 1 ); ?>" />
  </p>
  <!-- .form-username -->

  <p class="form-email">
    <strong>E-MAIL</strong>
    <input class="text-input" name="email" type="text" id="email" value="<?php if ( $error ) echo wp_specialchars( $_POST['email'], 1 ); ?>" />
  </p>
  <!-- .form-email -->

  <p class="form-password">
  <strong>CONFIRM E-MAIL</strong>
  <input type="text" name="user_pass" id="user_pass" class="input" value="" size="20" tabindex="10" />
  </p>

  <p class="form-publication">
  <strong>MEDIA OUTLET</strong>
    <input class="text-input" name="publication" type="text" id="publication" value="<?php if ( $error ) echo wp_specialchars( $_POST['publication'], 1 ); ?>"/>
  </p>
  <!-- .form-publication -->

  <p class="form-submit"> <?php echo $referer; ?>
    <input name="adduser" type="submit" id="addusersub" class="submit button" value="<?php if ( current_user_can( 'create_users' ) ) _e('Add User', 'frontendprofile'); else _e('Register', 'frontendprofile'); ?>" />
    <?php wp_nonce_field( 'add-user' ) ?>
    <input name="action" type="hidden" id="action" value="adduser" />
  </p>
  <!-- .form-submit -->

</form>

<script type="text/javascript">
$(document).ready(function(){

  $("input[name$='usertype']").click(function(){

  var radio_value = $(this).val();

  if(radio_value=='Media') {
     $("p.form-publication").show();
  }
  else if(radio_value=='Student') {
    $("p.form-publication").hide();
  }
  else if(radio_value=='Freelance') {
    $("p.form-publication").hide();
  }
  }); 
});
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:31:57+00:00Added an answer on May 29, 2026 at 6:31 am

    Your pluggin is not respecting the expected action hook format that you’d normally use. What you have to do here is to hook two different functions for your pluggin.

    One will draw the pluggin when necessary, using a shortcode for example.

    The other will hook into the early processing of wordpress to actually do what it’s got to do such as adding a user. Then, if you use wp_redirect it will allow you to redirect before any output is sent to the browser.

    For example, in my pluggins, i use the hooks:

    add_action('init', 'my_function_to_process');
    add_action('template_redirect', 'my_function_to_draw');
    

    And i create those two functions to do what they have to do in my pluggin’s file.

    You might want to check out the hooks database api for more information on hooks:

    http://codex.wordpress.org/Plugin_API/Action_Reference

    Good luck

    EDIT

    Just change:

    wp_redirect( 'http://www.google.com' );
    

    For:

    ?><script>window.href.location = "http://www.google.com";</script><?php exit();
    

    And you would be on your way to victory… It’s ugly in terms of integration, i’d have done it with a pluggin but it should work fine…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created custom registration form in drupal 6. i have used changed the
I have a custom user registration form at: somepath/register using hook form alter. I
I have a custom registration BrowserView where you have to extend some userdata (z3c.form
In a custom module nade_reg I have changed the registration form to include two
I have one registration page which uses custom valiadtor public class CustomValidator implements Validator
I have coded custom form validation. validation is working fine all browser but when
I have a client that needs a custom registration form. I need to make
I have successfully implemented a custom redirect after a failed login outline in these
I have custom map image with specific height and width. i need to map
I have a user registration form that has a password and confirm password field.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.