WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have added a custom field to user profiles in bbPress however I am unsure how to do form validation other than javascript. I would like to do some PHP validation however the few things I have tried didn't work.

If you fail to enter an email it will say "ERROR: Please enter an e-mail address." after you have submitted the form. I want something like that.

I have tried:

$myErrors = new WP_Error();
$myErrors->add('id_error', __('Test error.',""));

bbp_add_error( 'bbp_steamid_invalid', __( '<strong>ERROR</strong>: The ID you entered is invalid.', 'bbpress' ) );

I am not at all familiar with error handling in both WordPress and bbPress however I feel it is a must.

Any help would be must appreciated.

share|improve this question
up vote 0 down vote accepted

I worked it out.

add_action( 'user_profile_update_errors', 'validate_steamid_field' );

function validate_steamid_field(&$errors, $update = null, &$user  = null)
    if (!preg_match("/^STEAM_[0-5]:[01]:\d+$/", $_POST['_bbp_steamid']))
        $errors->add('empty_steamid', "<strong>ERROR</strong>: Please Enter a valid SteamID");
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.