Support

Account

Home Forums General Issues Disabled option for select fields Reply To: Disabled option for select fields

  • The validate function would be a great solution – however, this custom field is injected in the user registration form, so it doesn’t seem to trigger the validation functions.

    I could be wrong (maybe misconfigured function) but if I’m right, you might want to consider hooking your validation function into the registration form, since adding fields to the user_form = registration is a built-in feature of your system.

    I was able to validate the field (and trigger the native WP registration errors) through the registration_errors() hook. However, that brings me to a different problem.

    When I var_dump the $_POST variable in this function, it includes the data I want, but it’s attached to an obscure field_ key:

    array(10) {
      ["user_login"]=>   string(11) "johnsmith"
      ["user_email"]=>   string(23) "johnsmith@example.com"
      ["_acf_post_id"]=>   string(6) "user_0"
      ["_acf_nonce"]=>   string(10) "8294e063ae"
      ["_acf_validation"]=>   string(1) "1"
      ["_acf_ajax"]=>   string(1) "0"
      ["_acf_changed"]=>   string(1) "1"
      ["acf"]=>
      array(1) {
        ["field_5999b7f405d29"]=>
        string(11) "Candlestick Maker"
      }
      ["redirect_to"]=>   string(27) "https://example.com/welcome"
      ["wp-submit"]=>   string(8) "Register"
    }

    I can validate that field (in your solution, check against “not allowed”). But I’m unclear on how to access this field_ key value (in this case, “field_5999b7f405d29“). I can do a var_dump like this and see it, I could reverse engineer it from the database, but is there a way to get that key that’s more intuitive and portable?

    * Note the user_ ID is not established at this point, so I can’t, for example, access the field like so:

    get_field('occupation', 'user_22');