Hi James 🙂
XML file is here: https://dl.dropboxusercontent.com/u/167786/advanced-custom-field-export.xml
Changing theme to 2014, 2015 or 2016 makes no difference, same errors.
Second one worked perfectly, thanks 🙂
Brilliant 🙂 thanks (again) John.
Hi John,
Well, after a couple of hours wondering why your perfectly logical code wasn’t working, it turns out that my client is still using ACF4 and I just assumed (yup, I’m an ass) it was v5.
So, anyway, until they’re happy to upgrade to v5 here’s my working v4 code which is very similar to yours – the main difference being the apply_filters
on line 3:
$groupID = 92;
$fields = array();
$fields = apply_filters('acf/field_group/get_fields', $fields, $groupID);
if($fields) {
foreach( $fields as $field) {
if ($field['type'] == 'email') {
echo "<li>" . $field['label'] . "</li>";
}
}
}
Thanks for your help, it definitely made things a lot easier.
Hi John,
EDIT: I should’ve specified, all this action should happen inside functions.php, not on the front end of the site.
Thanks for your reply but no – its nothing to do with users I just want to get the value of the name
attribute of every field that is an email type field from a certain Field Group.
So I have a Field Group I’ve called ‘Additional Fields for User Profile’ which is – as the name suggests – some extra fields for the User Profile page. Some of these are email fields with their Field Type set to ’email’ – what I want to do is get the value of the name
attribute of every field that has a type of email
so:
<input id="acf-field-contact_email" class="email" name="fields[field_52e10709850b3]" value="[email protected]" placeholder="" type="email">
for this field (which has a type of email
) I need to get the value: fields[field_52e10709850b3] from the name
attribute.
Thanks
Hi John,
Thanks again for your input 🙂
It looks like I might’ve solved the mystery!
Just on a hunch I created a brand new user and then logged in as them. It worked just fine. So the only reason it didn’t seem to be working was because it *was* acting correctly – e.g. an existing user had probably already chosen a county.
But thank you – at the very least because of your help I’ve discovered other things I can do with ACF!
Kev
Hi John,
Thanks for your guidance 🙂
Just so I understand you correctly, here’s a screenshot of my settings when creating the Custom Field:
https://dl.dropboxusercontent.com/u/167786/acf-select-1.png
And here’s a screenshot of how it appears to the user:
https://dl.dropboxusercontent.com/u/167786/acf-select-1-user.png
As you can see, -Select- is added, but it still gets ignored in favour of the first actually entry (Aberdeenshire). If I switch to this:
https://dl.dropboxusercontent.com/u/167786/acf-select-2.png (with allow null now set to ‘No’. Then the user gets this with no -Select-
https://dl.dropboxusercontent.com/u/167786/acf-select-2-user.png
With the first case I inspected the select box element and saw this:
https://dl.dropboxusercontent.com/u/167786/acf-select-3-user.png
As you can see the -Select- option is ignored and ‘Aberdeenshire’ is selected like so: <option value="Aberdeenshire" selected="selected">Aberdeenshire</option>
I should also note I have tried both of those set ups above with a default value of null as here:
https://dl.dropboxusercontent.com/u/167786/acf-select-4.png
And also -Select – as here:
https://dl.dropboxusercontent.com/u/167786/acf-select-5.png
Is this what you’d expect to see based on your explanation above?
Thanks,
Kev
Just FYI I have got b) working. Any help on a) much appreciated.
I should add, I do not need ACF to handle anything to do with registration, I have sorted that out already and only added it to my question for background info.
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.