Structuring function with registration_errors hook
The variable $errors is an instance of WP_Error. WordPress has done all internal logic before the filter is used, so you can check for existing errors: function add_user_to_SF($errors, $sanitized_user_login, $user_email ) { if ( $errors->get_error_code() ) return $errors; global $SF_USERNAME; // continue with your custom code …