0

当我在 url 路径 'wp-login.php?action=register' 之外使用注册表单时,它会返回错误

( ! ) SCREAM: Error suppression ignored for
( ! ) Fatal error: Call to undefined function register_new_user() in     C:\wamp\www\mysite-t\wp-content\themes\mysite\functions\theme-access.php on line 74
Call Stack
#   Time    Memory  Function    Location
1   0.0003  676128  {main}( )   ..\index.php:0
2   0.0005  680960  require( 'C:\wamp\www\mysite-t\wp-blog-header.php' )      ..\index.php:17
3   0.0008  707056  require_once( 'C:\wamp\www\mysite-t\wp-load.php' )  ..\wp-blog-header.php:12
4   0.0011  725040  require_once( 'C:\wamp\www\mysite-t\wp-config.php' )    ..\wp-load.php:29
5   0.0019  858224  require_once( 'C:\wamp\www\mysite-t\wp-settings.php' )  ..\wp-config.php:90
6   1.2878  34464032    do_action( )    ..\wp-settings.php:308
7   1.3151  34734896    call_user_func_array ( )    ..\plugin.php:406
8   1.3151  34734928    edd_post_actions( ) ..\plugin.php:406
9   1.3151  34735016    do_action( )    ..\actions.php:40
10  1.3151  34736392    call_user_func_array ( )    ..\plugin.php:406
11  1.3151  34736424    forest_process_registre_form( ) ..\plugin.php:406

这是我的表格

<form id="registre_form"  class="horizontal-form" action="" method="post">
                      <fieldset>

                        <div class="input-group">
                            <label for="user_login"><?php echo __( 'Username', 'forest' ); ?>:</label>
                            <div class="inputs">
                              <input name="user_login" id="user_login" class="required" type="text" value="<?php echo isset($_POST['user_login']) ? esc_attr(stripslashes($_POST['user_login'])):''; ?>"/>
                            </div>
                        </div>

                        <div class="input-group">
                            <label for="user_email"><?php echo __( 'E-mail Addy', 'forest' ); ?>:</label>
                            <div class="inputs">
                              <input name="user_email" id="user_email" class="required" type="text" value="<?php echo isset($_POST['user_email']) ? esc_attr(stripslashes($_POST['user_email'])):''; ?>"/>
                            </div>
                        </div>

                        <div class="input-group">
                            <div class="inputs">
                             <em><?php echo __( 'The password will be e-mailed to you.', 'forest' ); ?></em>
                            </div>
                        </div>

                        <div class="form-submit">
                             <input type="hidden" name="edd_redirect" value="<?php bloginfo('url') ?>/wp-login.php?action=register&success=ok"/>
                            <input type="hidden" name="edd-registre-nonce" value="<?php echo wp_create_nonce( 'edd-registre-nonce' ); ?>"/>
                            <input type="hidden" name="edd_action" value="user_registre"/>
                            <button type="submit" class="btn-icon submit"><?php echo __( 'Create Account', 'forest' ); ?></button>
                        </div>

                    </fieldset>
                </form>

这是处理 register_new_user() 失败的函数

function forest_process_registre_form( $data ) {
if ( wp_verify_nonce( $data['edd-registre-nonce'], 'edd-registre-nonce' ) ) {

    $errors = register_new_user($data['user_login'], $data['user_email']);
    if ( isset($errors) && is_array($errors) ){
        foreach($errors as $error) {
            if(count($error) > 0) {
                foreach($error as $e) {
                    edd_set_error( 'email_incorrect', $e[0]);
                }
            }
        }
    }
    // Check for errors and redirect if none present
    $errors = edd_get_errors();
    if ( ! $errors ) {
        $redirect = apply_filters( 'edd_login_redirect', $data['edd_redirect'], $user_ID );
        wp_redirect( $redirect );
        exit;
    }
}
}
 add_action( 'edd_user_registre', 'forest_process_registre_form' );

它在 url = wp-login.php?action=register 时在注册页面上工作,但当它位于该页面之外的任何 url 上时无法完成该功能。有什么办法可以纠正这个问题,可以做 inb wordpress 吗?

4

1 回答 1

1

确保任何人都可以注册在 wp-admin 选项中设置为 true,它在 Administration > Settings > General 下

于 2013-09-13T13:55:26.913 回答