Hooks reference: filters
12 min read
Filters let you change a value. Every filter must return a value of the type shown in Returns; the plugin ignores or replaces a wrong type for most of them, but returning something unexpected is a bug in your code. Actions are on Hooks reference: actions.
- Plan: Free filters are in every build. Pro filters exist only where Pro code is present.
- Declare the number of arguments you read:
add_filter( 'wpmcf/...', $callback, 10, 3 ). $objectIdis the post, user, term or comment ID of the value being read; for options values it can benullor0.
Contents
Reading and printing field values · Global Data output · Variables · Field groups, location rules and storage · Shortcodes, queries and options pages · Admin screens · Admin columns · Post types and taxonomies · Local JSON · Background jobs and database · Page cache · Page builders · Licensing (Pro) · AI (Pro) · Data tables (Pro) · Forms (Pro) · Programmatic SEO (Pro)
Reading and printing field values
The order for one field read is: stored value → wpmcf/field/value → {{ }} evaluation (if allowed) → escaping for the output format → wpmcf/field/the_escaped → markup → wpmcf/field/the_html.
wpmcf/field/value
Plan | Free |
Arguments |
|
Returns |
|
Default | The stored value (or the |
Runs | On every read through |
add_filter( 'wpmcf/field/value', function ( $value, $group, $field ) {
if ( $group === 'product' && $field === 'price' && is_numeric( $value ) ) {
return $value * 1.2; // show prices with tax
}
return $value;
}, 10, 3 );wpmcf/field/the_escaped
Plan | Free |
Arguments |
|
Returns |
|
Runs | In |
You are responsible for the safety of what you return. Escape anything you add.
wpmcf/field/the_html
Plan | Free |
Arguments |
|
Returns |
|
Runs | Last step of |
add_filter( 'wpmcf/field/the_html', function ( $markup, $group, $field ) {
return $group === 'product' && $field === 'badge' ? '<strong>' . $markup . '</strong>' : $markup;
}, 10, 3 );wpmcf/field/the_password
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | Whenever the plugin decides whether a password field may leave the database through a template path. The hashed storage mode is never revealed regardless. |
add_filter( 'wpmcf/field/the_password', '__return_true' ); // the site accepts printing stored passwordswpmcf/field/resolve_variables
Plan | Free |
Arguments |
|
Returns |
|
Default | Post: the post author has |
Runs | Once per string value read through the field runtime that contains |
Examples and the reasoning are on Security.
wpmcf/field/repeater_html
Plan | Free |
Arguments |
|
Returns |
|
Runs | When a repeater value is turned into the default list markup ( |
wpmcf/field/flexible_content_html
Plan | Pro |
Arguments |
|
Returns |
|
Runs | When a flexible content value is turned into the default markup ( |
Global Data output
Same shape as the field filters, for Global Data.
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Free |
|
| On every read ( |
| Free |
|
| In |
| Free |
|
| Last step of printing; |
| Free |
|
| Decides whether a password variable can be printed or read through |
add_filter( 'wpmcf/global/value', function ( $value, $key ) {
return $key === 'phone' ? preg_replace( '/\s+/', ' ', (string) $value ) : $value;
}, 10, 2 );Variables
wpmcf/variables/context
Plan | Free |
Arguments |
|
Returns |
|
Runs | At the start of every top-level evaluation (not for nested blocks). Add request data with |
add_filter( 'wpmcf/variables/context', fn ( $ctx ) => $ctx->withMeta( 'campaign', 'spring-sale' ) );wpmcf/variables/allowed_options
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | On every |
Add only options that are safe on a public page. See Security.
Field groups, location rules and storage
wpmcf/fields/initial_values
Plan | Free (Business adds the translation prefill) |
Arguments |
|
Returns |
|
Default |
|
Runs | On a post edit screen when the post has no stored row for the group yet. Use it to prefill a new post (a new translation is prefilled from its original this way). |
wpmcf/fields/translation_ui
Plan | Free (set to |
Arguments |
|
Returns |
|
Default |
|
Runs | When field builder data is prepared. |
wpmcf/fields/schema_background_rows
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When a table change is planned. Changes on tables with more rows than this run in the background; a change that rewrites stored values switches at 5,000 rows at most. |
wpmcf/field_groups/builder_pages
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When screen data is localized. Pages in the list receive the field type metadata ( |
wpmcf/field_groups/managed_by
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When a field group is returned over REST. A managed group is read-only in the editor and refuses |
wpmcf/location/params
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When location rules are checked. Valid contexts are |
wpmcf/location/actual_value
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | For every rule whose parameter is not built in. |
wpmcf/location/ui_params
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When field builder data is prepared ( |
wpmcf/location/options_pages
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When the rule builder asks which options pages exist. |
Shortcodes, queries and options pages
wpmcf/shortcode/can_view
Plan | Free |
Arguments |
|
Returns |
|
Default | Post: the visitor can read it and it is not password-protected (editors always can). User: the visitor themself, the author of the post being displayed, or someone with |
Runs | When a shortcode, block or builder element asks for a value of an explicit object ( |
Options values inside post content are checked separately: the post's author must hold a capability from wpmcf/options/capabilities (default manage_options). This filter then receives that result with context options and ID 0. Outside any post, templates and widgets are trusted; REST and ajax requests need the capability themselves.
wpmcf/options/capabilities
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When options values appear in post content (shortcode, block, builder) and the author must be checked. |
add_filter( 'wpmcf/options/capabilities', fn ( $caps, $group ) => $group === 'contact' ? [ 'edit_others_posts' ] : $caps, 10, 2 );wpmcf/query/public_orderby
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | On the front-end main query when the URL's own |
Admin screens
wpmcf/admin/localize_data
Plan | Free |
Arguments |
|
Returns |
|
Runs | When a plugin screen's script is localized. Add keys for your own script; do not remove existing keys. |
wpmcf/admin/docs_links
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When help links are built. Known topics: |
wpmcf/onboarding/checklist
Plan | Free |
Arguments |
|
Returns |
|
Runs | When the dashboard checklist is built. |
Admin columns
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Free |
|
| Before columns are added to a list table. |
| Free |
|
| For each cell rendered. |
| Pro |
|
| When a column would get a filter control. |
| Pro |
|
| When a column would get inline (quick and bulk) editing. |
add_filter( 'wpmcf/admin_columns/editable', function ( $enabled, $column ) {
return $column['field'] === 'price' ? false : $enabled;
}, 10, 2 );Post types and taxonomies
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Free |
|
| Right before registration. |
| Free |
|
| Right before registration. |
| Free |
|
| When a stored definition names a callback (such as |
| Free |
|
| Same for taxonomies. Default: WordPress's own |
add_filter( 'wpmcf/post_types/register_args', function ( $args, $name ) {
if ( $name === 'book' ) {
$args['menu_icon'] = 'dashicons-book';
}
return $args;
}, 10, 2 );Local JSON
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Free |
|
| When definitions are saved. Default: |
| Free |
|
| When definitions are read. Default: the save folder, plus the parent theme's |
| Free |
|
| Whether saving to Local JSON is on. Default: the save folder exists. Return |
See Local JSON and version control.
Background jobs and database
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Free |
|
| Each time a background batch starts. Default |
| Free |
|
| When the schema manager is created. A module adds its own migrations, hooked from its provider's |
add_filter( 'wpmcf/jobs/batch_seconds', fn () => 10 );Page cache
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Free |
|
| Before every purge. Default: the Settings option "clear page caches". |
| Free |
|
| When the purger resolves which cache plugins to talk to (once per request). Add an adapter for a cache plugin that is not built in. |
add_filter( 'wpmcf/cache/enabled', '__return_false' ); // never touch page cachesPage builders
wpmcf/integrations/elementor/widgets
Plan | Free |
Arguments |
|
Returns |
|
Default |
|
Runs | When the Elementor widgets are registered. |
Licensing (Pro)
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Pro |
|
| When the end of the grace period after a license expired is computed. Default |
| Pro |
|
| When the expiry notice is drawn: download links for data the owner can still take out (data tables add each table's CSV). |
AI (Pro)
wpmcf/ai/providers
Plan | Pro |
Arguments |
|
Returns |
|
Default |
|
Runs | The first time the provider list is needed. Add or replace a provider, for example a stub in tests. |
Data tables (Pro)
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Pro |
|
| When a CSV feed URL is checked. Default: |
| Pro |
|
| Before a feed is downloaded. Default 20 MB. |
| Pro |
|
| Per feed request. Default 30. |
| Pro |
|
| When an uploaded CSV is accepted. Default 50 MB. |
| Pro |
|
| When a CSV is not UTF-8: the Windows code page to try ( |
| Pro |
|
| When the data tables list shows "used by". Add |
add_filter( 'wpmcf/data_tables/feed_hosts', function ( $hosts ) {
$hosts[] = 'example.com';
return $hosts;
} );Forms (Pro)
Hook | Plan | Arguments | Returns | Runs |
|---|---|---|---|---|
| Pro |
|
| After the built-in checks passed. Use it for CAPTCHA or Turnstile. |
| Pro |
|
| Per submission. Default |
| Pro |
|
| When the visitor IP is read for the rate limiter. Default: |
| Pro |
|
| For each file field. Default: the smaller of the server upload limit and the plugin cap. |
| Pro |
|
| For a file field without its own list when the visitor cannot upload files. Default: |
| Pro |
|
| When a registration form lists assignable roles. Narrow only: it starts with the roles that carry no powerful capability, and roles you add that are unsafe are ignored. |
| Pro |
|
| When a registration password is checked. Default: 10 or more characters, at least 2 of the 4 character classes, contains a letter, not containing the login. |
| Pro |
|
| When connections to other form plugins are set up. Add an object implementing |
add_filter( 'wpmcf/forms/verify_submission', function ( $ok, $form, $request ) {
if ( empty( $request['cf-turnstile-response'] ) ) {
return new WP_Error( 'captcha', 'Please complete the check.' );
}
return $ok;
}, 10, 3 );Programmatic SEO (Pro)
wpmcf/pseo/conversion/skip_meta_keys
Plan | Pro |
Arguments |
|
Returns |
|
Default |
|
Runs | For each converted page. |
JavaScript filter
wpmcf.settings.tabs (@wordpress/hooks): a map of Settings section ID to React component, used with the wpmcf/settings/register_sections action to add a tab to the Settings screen.
Still stuck? Contact support