Title: Manage WordPress Errors
Last modified: August 19, 2016

---

# Manage WordPress Errors

 *  [remus](https://wordpress.org/support/users/remus/)
 * (@remus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/manage-wordpress-errors/)
 * Hello,
 * I am building a custom registration plugin and had everything working all right,
   except showing the eventual errors on the front page.
 * This is a brief example of the functions I’m using, some of the code has been
   cut out for “keeping it simple” reasons, but mostly similar with code from wp-
   login.php:
 *     ```
       add_action('init', 'rms_check_login');
   
       function rms_check_login() {
   
          $user_login = sanitize_user( $_POST['username'] );
          $user_email = apply_filters( 'user_registration_email', $_POST['email'] );
           ........................................................
          // check form fields for errors
          if ( $user_login == '' ) {
             $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) );
          }
           ...................................................................
          $errors = new WP_Error();
   
          if ( $errors->get_error_code() ) {
              // !!! need to capture errors and show them on the front-end !!!
              return $errors->get_error_message();
          } else {
             // insert new user and send notification
             $user_pass = wp_generate_password();
             $user_id = wp_create_user($user_login, $user_pass, $user_email);
             .................................................................
             wp_redirect( $redirect_to );
             exit;
          }
       }
       ```
   
 * I don’t know what I’m doing wrong but I am not able to capture the eventual errors
   and show them on the front page, please help!
 * The custom registration form is part of a regular WordPress page (e.g. [http://mydomain.com/registration-form/](http://mydomain.com/registration-form/)).
 * Thank you very much for your time and looking forward for your thoughts.
 * Best regards.

Viewing 1 replies (of 1 total)

 *  Thread Starter [remus](https://wordpress.org/support/users/remus/)
 * (@remus)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/manage-wordpress-errors/#post-1583354)
 * Or if maybe this isn’t the best to do it, please let me know your ideas on how
   would you work with it. I would really appreciate it.
 * Thanks.

Viewing 1 replies (of 1 total)

The topic ‘Manage WordPress Errors’ is closed to new replies.

## Tags

 * [errors](https://wordpress.org/support/topic-tag/errors/)
 * [management](https://wordpress.org/support/topic-tag/management/)
 * [wp_error](https://wordpress.org/support/topic-tag/wp_error/)

 * 1 reply
 * 1 participant
 * Last reply from: [remus](https://wordpress.org/support/users/remus/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/manage-wordpress-errors/#post-1583354)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
