通过前端注册表在wordpress中创建多个用户角色

通过前端注册表在wordpress中创建多个用户角色,wordpress,Wordpress,我创建了前端注册表及其工作模式。我尝试创建2个具有2个用户角色的注册表。但我不能通过前端创建2个用户,任何一个都可以帮助我 候选人登记表 <section class="job-seeker-reg-area body-bg"> <div class="container"> <div class="row"> <div class="col-md-12"> <div c

我创建了前端注册表及其工作模式。我尝试创建2个具有2个用户角色的注册表。但我不能通过前端创建2个用户,任何一个都可以帮助我

候选人登记表

<section class="job-seeker-reg-area body-bg">
      <div class="container">
        <div class="row">
          <div class="col-md-12">
            <div class="page-title page-title-border page-title-small">
                 <?php if ( $atts['show_title'] ) : ?>
                    <h1>><?php _e( 'CREATE JOB SEEKER PROFILE', 'test' ); ?></h1>
                <?php endif; ?>

            </div>
          </div>
          <div class="col-md-8 col-md-offset-2">
            <div class="social-login">
              <i class="fab fa-linkedin-in"></i>
              <a href="#">Sign in with LinkedIn</a>
            </div>
            <div class="login-wall">
              I already have a Job Seeker account. <a href="#">Sign me in</a>
            </div>
            <?php if ( count( $atts['errors'] ) > 0 ) : ?>
                <?php foreach ( $atts['errors'] as $error ) : ?>
                    <p>
                        <?php echo $error; ?>
                    </p>
                <?php endforeach; ?>
            <?php endif; ?>
            <form action="<?php echo wp_registration_url(); ?>" method="POST" id="signupform">
              <div class="form-group">
                <label for="name">Full Name</label>
                <input type="text" class="form-control" id="name" name="fullname">
              </div>
              <div class="form-group">
                <label for="email">Email *</label>
                <input type="email" class="form-control" id="email" required name="email">
              </div>
              <div class="form-group">
                <label for="password">Password *</label>
                <input type="password" class="form-control" id="password" required name="password">
              </div>
              <div class="form-group">
                <label for="con_password">Confirm Password *</label>
                <input type="password" class="form-control" id="con_password" required name="confirmpassword">
              </div>
              <div class="checkbox">
                <label>
                  <input type="checkbox" required name="check">  <a href="#">I agree to the terms of use *</a>
                </label>
              </div>
              <input type="submit" name="submit" class="btn btn-default btn-orange"
                   value="<?php _e( 'Register', 'test' ); ?>"/>
            </form>
          </div>
        </div>
      </div>
    </section>
雇主登记表格

    <section class="job-seeker-reg-area body-bg">
      <div class="container">
        <div class="row">
          <div class="col-md-12">
            <div class="page-title page-title-border page-title-small">
               <?php if ( $atts['show_title'] ) : ?>
                    <h1>><?php _e( 'CREATE Employer PROFILE', 'test' ); ?></h1>
                <?php endif; ?>
            </div>
          </div>



          <div class="col-md-8 col-md-offset-2 col-sm-12">
            <div class="social-login">
              <i class="fab fa-linkedin-in"></i>
              <a href="#">Sign in with LinkedIn</a>
            </div>
            <div class="login-wall">
              I already have an Employer account. <a href="#">Sign me in</a>
            </div>

            <?php if ( count( $atts['errors'] ) > 0 ) : ?>
              <?php foreach ( $atts['errors'] as $error ) : ?>
                  <p>
                      <?php echo $error; ?>
                  </p>
              <?php endforeach; ?>
          <?php endif; ?>
            <form action="<?php echo wp_registration_url(); ?>" id="signupformemployer" method="POST">
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="name">Full Name</label>
                  <input type="text" class="form-control" id="name" name="fullnameemployer">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="email">Email *</label>
                  <input type="email" class="form-control" id="email" required name="emailemployer">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="password">Password *</label>
                  <input type="password" class="form-control" id="password" required name="passwordemployer">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="con_password">Confirm Password *</label>
                  <input type="password" class="form-control" id="con_password" required name="confirmpasswordemployer">
                </div>
              </div>
              <div class="col-md-12 col-sm-6">
                <div class="form-group">
                  <label for="company_name">Company Name *</label>
                  <input type="text" class="form-control" id="company_name" required name="companyname">
                </div>
              </div>
              <div class="col-md-12 col-sm-6">
                <div class="form-group">
                  <label for="location">Company Type</label>
                  <select class="form-control" name="companytype">
                    <option>Select Company Type</option>
                    <option>Direct Employer</option>
                    <option>Recruitment Agency</option>
                    <option>Other</option>
                  </select>
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="location">Location</label>
                  <input type="text" class="form-control" id="location" name="companylocation">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="phone">Phone</label>
                  <input type="text" class="form-control" id="phone" name="companyphone">
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <label for="website">Website</label>
                  <input type="text" class="form-control" id="website" name="companywebsite">
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <label for="logo">Logo</label>
                  <input type="file" id="logo" name="companylogo">
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <textarea class="form-control" rows="10" name="companydesc"></textarea>
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <div class="checkbox" name="companycheckbox">
                    <label>
                      <input type="checkbox" required>  <a href="#">I agree to the terms of use *</a>
                    </label>
                  </div>
                </div>
              </div>
               <input type="submit" name="submitemployer" class="btn btn-default btn-orange"
                   value="<?php _e( 'Register', 'test' ); ?>"/>
            </form>
          </div>
        </div>
      </div>
    </section>

“但我不能通过前端创建2个用户”是什么意思?会发生什么?是否涉及任何错误消息?“我无法通过前端注册表创建2种类型的用户”,这意味着什么?为什么你不能这样做呢?假设我想创建两种类型的用户,雇主和求职者。我为他们的注册创建了两个不同的表单。当我填写求职者登记表时,它会起作用。但当我试图以同样的方式填写雇主登记表时,它不起作用意味着它不能创建用户。结果会怎样呢?什么都没有?
    <section class="job-seeker-reg-area body-bg">
      <div class="container">
        <div class="row">
          <div class="col-md-12">
            <div class="page-title page-title-border page-title-small">
               <?php if ( $atts['show_title'] ) : ?>
                    <h1>><?php _e( 'CREATE Employer PROFILE', 'test' ); ?></h1>
                <?php endif; ?>
            </div>
          </div>



          <div class="col-md-8 col-md-offset-2 col-sm-12">
            <div class="social-login">
              <i class="fab fa-linkedin-in"></i>
              <a href="#">Sign in with LinkedIn</a>
            </div>
            <div class="login-wall">
              I already have an Employer account. <a href="#">Sign me in</a>
            </div>

            <?php if ( count( $atts['errors'] ) > 0 ) : ?>
              <?php foreach ( $atts['errors'] as $error ) : ?>
                  <p>
                      <?php echo $error; ?>
                  </p>
              <?php endforeach; ?>
          <?php endif; ?>
            <form action="<?php echo wp_registration_url(); ?>" id="signupformemployer" method="POST">
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="name">Full Name</label>
                  <input type="text" class="form-control" id="name" name="fullnameemployer">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="email">Email *</label>
                  <input type="email" class="form-control" id="email" required name="emailemployer">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="password">Password *</label>
                  <input type="password" class="form-control" id="password" required name="passwordemployer">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="con_password">Confirm Password *</label>
                  <input type="password" class="form-control" id="con_password" required name="confirmpasswordemployer">
                </div>
              </div>
              <div class="col-md-12 col-sm-6">
                <div class="form-group">
                  <label for="company_name">Company Name *</label>
                  <input type="text" class="form-control" id="company_name" required name="companyname">
                </div>
              </div>
              <div class="col-md-12 col-sm-6">
                <div class="form-group">
                  <label for="location">Company Type</label>
                  <select class="form-control" name="companytype">
                    <option>Select Company Type</option>
                    <option>Direct Employer</option>
                    <option>Recruitment Agency</option>
                    <option>Other</option>
                  </select>
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="location">Location</label>
                  <input type="text" class="form-control" id="location" name="companylocation">
                </div>
              </div>
              <div class="col-md-6 col-sm-6">
                <div class="form-group">
                  <label for="phone">Phone</label>
                  <input type="text" class="form-control" id="phone" name="companyphone">
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <label for="website">Website</label>
                  <input type="text" class="form-control" id="website" name="companywebsite">
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <label for="logo">Logo</label>
                  <input type="file" id="logo" name="companylogo">
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <textarea class="form-control" rows="10" name="companydesc"></textarea>
                </div>
              </div>
              <div class="col-md-12 col-sm-12">
                <div class="form-group">
                  <div class="checkbox" name="companycheckbox">
                    <label>
                      <input type="checkbox" required>  <a href="#">I agree to the terms of use *</a>
                    </label>
                  </div>
                </div>
              </div>
               <input type="submit" name="submitemployer" class="btn btn-default btn-orange"
                   value="<?php _e( 'Register', 'test' ); ?>"/>
            </form>
          </div>
        </div>
      </div>
    </section>
private function register_user_employer( $emfullname, $ememail, $empassword, $emconfirmpassword, $companyname, $companytype, $companylocation, $companyphone, $companywebsite, $companylogo, $companydesc, $companycheckbox ) {
            $errors = new WP_Error();

            // Email address is used as both username and email. It is also the only
            // parameter we need to validate
            if ( ! is_email( $ememail ) ) {
                $errors->add( 'email', $this->get_error_message( 'email' ) );
                return $errors;
            }

            if ( username_exists( $ememail ) || email_exists( $ememail ) ) {
                $errors->add( 'email_exists', $this->get_error_message( 'email_exists') );
                return $errors;
            }

            // Generate the password so that the subscriber will have to check email...
            // $password = wp_generate_password( 12, false );

            $user_data = array(
                'user_login'    => $ememail,
                'user_email'    => $ememail,
                'user_pass'     => $empassword,
                'role'          => 'employer'
                // 'first_name'    => $first_name,
                // 'last_name'     => $last_name,
                // 'nickname'      => $first_name,

            );

            $user_id = wp_insert_user( $user_data );
            wp_new_user_notification( $user_id );

            return $user_id;
        }
------------------ its not working ---------------------