Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Ben Beard

Issue with sorting acf field that returns an array

Please forgive me if I leave anything out or need to include more info. I am AWFUL at trying to explain stuff.

So I have a site for people to create a login. Tied to each user is an acf field (select field) for user status. When a user signs up they are assigned the status of “pending” and as the users finish specific tasks the users status will change as needed.

For example the user would submit an application and the user status would change from “pending” to “app submitted”

So the user status was created in ACF as a select field that returns both the label and value. (Set to return an array)

I am using the admin columns plugin in dashboard user section. I want to be able to filter users based off of the users status (the acf select field)

So I have tried both using the simple and smart filter. Neither work in the sense that when I try to only show users with the status of …(whatever) none show up even though that column has that status showing.

However, if I use inline edit on that field to change the status then the filter will start working for that user.
I noticed that the data is changed to a string in the DB for any user whos status is changed via inline editing.

So I am kinda stumped on why the filter only works for data that is saved as just a string. Am I missing something?

If I need to include more info I will more than happy do so. Also here are the related plugins and the version

Admin Columns Pro 5.53
Admin Columns Pro – Advanced Custom Fields (ACF) 2.6.4

2 years, 7 months ago
Ben Beard

Sorry, also
Advanced Custom Fields PRO 5.10.2

2 years, 7 months ago
Stefan van den Dungen Gronovius
Developer

Is it correct that you store the field yourself on the front-end of your website?
You can set the return type for an ACF Select field to return both the label and value, but that does not change the way that the data is stored, which is just a single value. Our inline editing feature for the ACF Select field does store the actual value (not the label) as a single string in the database. You should do the same for the front-end form if you wrote the code yourself that stores the ACF Value. You can also see how it is done when you store the user yourself in the WordPress admin so you have an idea of what to store in the field.

2 years, 7 months ago
Ben Beard

So I looked and the data is serialized, (I assume this is the issue) this might be a dumb question but is there a hook I can run do de-serialize the data before its populated in the dashboard for the column?

2 years, 7 months ago
Stefan van den Dungen Gronovius
Developer

The data must be in the expected format in order to use the sorting and filtering feature of our plugin, so changing it on the fly before it renders, will not work. It is better to make sure that your data is stored exactly as ACF has intended because our plugin also expects the data to be in that format.

So in your case, you probably need to make some changed to your front-end form handler and run a migration script for the existing fields in your database. There is not a simple search and replace function/hook for that I’m afraid.

2 years, 7 months ago
Ben Beard

Gotcha, makes sense. Thanks for the help.

2 years, 7 months ago

You must be logged in to reply to this topic.