English (United Kingdom)

apply_filters_ref_array( 'vikappointments_load_custom_fields_rules', bool $status, array &$rules )

Fires while loading the list of supported custom fields rules.


Description

Trigger hook to allow external plugins to support additional rules for the custom fields.

New rules have to be appended to the given associative array. The key of the array is the unique ID of the rule, the value is a readable name of the rule.

All the values included within the $rules array will be reported as accepted options of the Rule dropdown under the management page of a custom field.


Parameters

$status

(bool)  True on success, false otherwise.

&$rules

(array)  An associative array holding all the supported rules.


Example

The example below adds support for a new rule that extracts the country code from the field.

/**
 * Trigger hook to allow external plugins to support custom rules.
 * New rules have to be appended to the given associative array.
 * The key of the array is the unique ID of the rule, the value is
 * a readable name of the rule.
 *
 * @param  boolean  $status  True on success, false otherwise.
 * @param  array    &$rules  An array of rules.
 */
add_filter('vikappointments_load_custom_fields_rules', function($status, &$rules)
{
    // add support for a new "country" rule
    $rules['country'] = __('Country', 'my-plugin');

    return $status;
}, 10, 2);

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-08-20
Helpful?
100% of people found this helpful.