query – ACF: Is there a way to calculate the amount of filled fields of field group(s)?


Does anybody know of a way to calculate the percentage of filled fields of a field group in ACF.

For example, let’s say I have a field group with only a few required fields and the rest of the fields are optional. What would be the process to calculate the amount of fields that are filled out (have a value).

I am thinking about something like selecting the field group and the usermeta/postmeta and compare the available values.

The challenge I see is to make sure the calculation process takes care of the dynamic display rules. So, when a field was not visible, it should not be counted in the percentage calculation.

So, the calculation can not be something like:


// selecting and counting set field counts …

$amount = $userMetaFieldsCount / $fieldGroupFieldsCount

It should rather be something like:


// Loop through field group(s) and follow the displays rules 
// and compare with another database entry like post or user

Anybody an idea of how to write such logic?


user1134827 2 years 2022-01-26T12:22:15-05:00 0 Answers 0 views 0

Leave an answer