Home › Forums › Bug Reports › Repeater on options page returns count
Hi,
I am getting a count of the repeater field items as a string only when using the repeater field on my options page instead of a multi-dimensional array of the sub-items. I have another repeater set up on the site that is not on the options page that works as expected.
I am on wordpress version 3.8 and ACF version 4.3.4
Thank you
In my functions.php, I am just running
$hidden_users = get_field('hide-users', 'options');
var_dump($hidden_users);
which produces
string(1) "2"
I tried adding/removing items from the list to verify that the number that it is outputting is the count.
Hi @ccernoch
Thanks for the code. The issue here is that you are using the get_field
function in the root of the functions.php file.
The repeater field add-on is currently included during the init
action. This action is run AFTER the functions.php file is read, so the issue you are seeing is that the repeater field is not yet loaded and can’t run it’s custom load_value logic.
To solve the issue, please hook into the init action and run your get_field
code there.
add_action('init', function(){
$hidden_users = get_field('hide-users', 'options');
var_dump($hidden_users);
});
Thanks
E
Hi Elliot,
Thank you for your fast reply and super awesome plugin. It does in fact work perfectly when added in the init action. I guess my issue now is that I am actually trying to use it in a filter to filter out buddypress members that are listed in the site, and apparently the bp_ajax_querystring filter is not running at a time when I can use the repeater fields 🙁
If you have any suggestions of how to get around it they would be much appreciated, otherwise I will have to figure something else out.
Thanks!
Hi @ccernoch
Thanks for the follow up. Good new is that this issue will be fixed in the next release. Should be out in the next week.
Thanks
E
The topic ‘Repeater on options page returns count’ is closed to new replies.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.