Hooks
Without ACF active, each wpff/… hook below that ACF also has runs as acf/… too. See ACF compatibility.
| Hook | Type | Purpose |
|---|---|---|
wpff/init | action | Register groups, options pages and blocks here. |
wpff/register_field_types | action | Add your own field type, a subclass of FreeformFields\Fields\AbstractField: $registry->register( new My_Field() ). |
wpff/load_value, wpff/format_value, wpff/update_value | filter | ( $value, $post_id, $field ). Also /type=…, /name=… and /key=… variants. |
wpff/validate_value | filter | ( $valid, $value, $field, $post_id ). Return a message string to reject the value. Also /type=, /name= and /key= variants. |
wpff/prepare_field | filter | ( $field ), before the field is rendered. Return false to hide the field. |
wpff/pre_update_value | filter | Return false to skip saving a value. |
wpff/save_post | action | ( $post_id, $errors ), after a form is saved. |
wpff/save_field_group, wpff/delete_field_group | action | After a group is saved or deleted in the admin. |
wpff/load_field_groups | filter | All groups, before they are normalized. |
wpff/location/matchers | filter | Custom location rules: 'param' => fn( $rule, $screen ) => bool. |
wpff/settings/save_json, wpff/settings/load_json | filter | Local JSON folders. |
wpff/settings/{name} | filter | A setting value. |
wpff/options_autoload | filter | Whether options page values are autoloaded. |
wpff/capability | filter | Capability needed to manage field groups. Default: manage_options. |
wpff/acf_compat | filter | Whether to define functions with ACF's names. |
wpff/fields/google_map/api_key | filter | Google Maps API key. Return '' to use OpenStreetMap. |
wpff/fields/google_map/tiles | filter | Tile server: [ 'url' => …, 'attribution' => … ]. |
wpff/fields/google_map/geocoder_url | filter | A Nominatim-compatible geocoder. |
wpff/updates/enabled | filter | Whether to check GitHub releases for plugin updates. Default true. |
wpff/updates/manifest_url | filter | URL of the update manifest. Default: update.json of the latest release. |
Examples
Reject a value:
php
add_filter( 'wpff/validate_value/name=isbn', function ( $valid, $value ) {
if ( $value && ! preg_match( '/^[0-9-]{10,17}$/', $value ) ) {
return 'Enter a valid ISBN.';
}
return $valid;
}, 10, 2 );Hide a field from non-admins:
php
add_filter( 'wpff/prepare_field/name=internal_note', function ( $field ) {
return current_user_can( 'manage_options' ) ? $field : false;
} );