Support

Account

Home Forums Add-ons Options Page Extend conditional logic to be set from options page Reply To: Extend conditional logic to be set from options page

  • What you are looking to do is to dynamically set the location rules for field groups based on the values of an options page. This can be done. If you are not using JSON files you can use the acf/load_field_group hook

    
    add_filter('acf/load_field_group', 'your_function_name', 20);
    function your_function_name($group) {
      if ($group['key'] == 'group_YOUR_GROUP_KRY')) {
    
      }
    }
    

    if you are using json files, of just to be sure, you should use the acf/validate_field_group hook. The above hook is not called when loading json files.

    
    add_filter('acf/validate_field_group', 'your_function_name', 20);
    function your_function_name($group) {
      if ($group['key'] == 'group_YOUR_GROUP_KRY')) {
    
      }
    }
    

    In your filter you can check your options and set the location rules dynamically based on your checks. For examples of how the location rules work I would set some location rules in ACF and do an export to see how this value of the group needs to be added.