WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Validating Custom Profile Fields During Registration (3 posts)

  1. floatingpointmatt
    Member
    Posted 2 years ago #

    Hey everybody,

    A quick question about validating custom profile fields during the registration process...

    I've got fields showing, and in theory capturing based on the code at:

    http://wordpress.org/support/topic/howto-custom-registration-fields?replies=6

    Validation on register_post didn't seem to work though, so I followed through the Codex to registration_errors...

    http://codex.wordpress.org/Plugin_API/Filter_Reference/registration_errors

    Now I am able to interact with errors (which weren't available during register_post), but trying to register throws the following error:

    PHP Fatal error: Call to a member function get_error_code() on a non-object in ...\wp-login.php on line 316

    Trying to trace that error shows that it happens often with plugins that interact with registration (apparently Sabre is high on the list), but I get nothing in terms of a recommended fix.

    NOTE: I get the error whether I send things through empty (i.e. all errors on required fields) or completely filled in.

    I've confirmed I have a WP_Error object through the body of my validation function, and a print_r indicates all should be fine from start to finish (with a few errors getting added if appropriate) but it seems like the WP_Error object is getting mangled by the time it returns to wp-login.php...

    Has anybody seen anything on successfully adding and validating profile fields for WordPress 3.3.x and up?

    NOTE: I'd upgrade to 3.4.x but I'd rather fight this battle, then worry about plugin compatibilities, etc.

    ADDITIONAL: I'm also doing this for a stronger integration with the admin than a plugin like WP-Members offers (which works, but works differently... and undesirably so).

    Any assistance would be greatly appreciated!

    Thanks,

    Matt

  2. MG7282
    Member
    Posted 1 year ago #

    Did you find a solution for this?

  3. floatingpointmatt
    Member
    Posted 1 year ago #

    Actually, I did... though I'm not sure it really registered at the time why...

    On recent review, the article I was using as a guide uses the following function signature:

    function check_fields($login, $email, $errors)

    However, the API call is actually:

    function myplugin_check_fields($errors, $sanitized_user_login, $user_email)

    Notice the position of $errors...

    It should be first according to:

    http://codex.wordpress.org/Plugin_API/Filter_Reference/registration_errors

    Best of luck!

Topic Closed

This topic has been closed to new replies.

About this Topic