Nearly two months later, and still marked “unread”
I can see how the tabs toggle to active with the class “active” added to the <li>
.
I also see that clicking the tabs toggle visibility on items in the tabs by adding or removing the “hidden-by-tab” class.
So far, so good. What I don’t see right away is how ACF identifies which fields are associated with a given tab. So I can create the dropdown selector which would trigger the event and I could manually add the field names (e.g. acf-field-599a68e5b5919) or the data-name attribute (e.g. address_1).
But how can I programmatically distinguish and select the divs for the different tabs?
It’s a bit of a challenge to climb through the jQuery code, could you provide a sample of how the plugin does it, so I (and others with this challenge in the future) can have a roadmap to implementing such a solution? Happy to post my code when I get a final working version.
Thanks!
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) "[email protected]"
["_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');
I am using ACF Pro (5) and am adding fields to the registration form, but via the backend.
You’re suggesting adding say “NULL : Option 1” in the select option list, and then checking “NULL not allowed”. Very clever – but I don’t seem to be able to format the option with the value NULL. I used this exact format:
NULL : Option 1
Can you advise how to make a drop-box select option “NULL”?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.