Function reference
5 min read
All functions are global, defined in the free plugin, and safe to call at any time: before the plugin has booted they return the default, and failures are logged under Massbase › Settings › Health, never thrown. Common conventions are in the overview; object forms are in Object references.
Function | Purpose |
|---|---|
| Raw value of a field |
| Print a field, escaped |
| Does the field have a value |
| Save a value |
| Clear a value |
| Raw options-page value |
| Print an options-page value |
| Options-page value present |
| Save an options-page value |
| Clear an options-page value |
| Verify a password field |
| Read an encrypted/plain password field |
|
|
| Raw Global Data value |
| Print a Global Data value |
| Global Data value present |
| Update a Global Data value |
Internal helpers |
|
Other functions | Variables, PHP-registered groups, WooCommerce |
Common arguments ($args)
Key | Functions | Meaning |
|---|---|---|
| get, has, the | Value used when the field has none ( |
| all field functions | Dot path or array of segments into a Group/Repeater value |
| all field functions | One-segment |
| functions with |
|
| the |
|
| the |
|
| functions with | Identify a widget for |
wpmcf_get_field
wpmcf_get_field( string $group_key, string $field_key, mixed $object = null, array $args = [] ): mixedRaw, unescaped value. Returns $args['default'] (else null) when the value is NULL or the group, field or object is missing or invalid. Resolves {{ }} expressions when the writer is trusted.
$price = wpmcf_get_field( 'listing', 'price', $post_id, [ 'default' => 0 ] );
$city = wpmcf_get_field( 'listing', 'details', $post_id, [ 'path' => 'city' ] );
$bio = wpmcf_get_field( 'profile', 'bio', 'user_3' );See Reading values.
wpmcf_the_field
wpmcf_the_field( string $group_key, string $field_key, mixed $object = null, array $args = [] ): voidEchoes the escaped, formatted value in <span class="wpmcf-field-value"> (turn off with 'wrap' => false). Prints nothing for empty values, Password fields and unformattable values. Invalid object: prints nothing.
wpmcf_the_field( 'listing', 'title' );
wpmcf_the_field( 'listing', 'description', null, [ 'format' => 'post_html', 'wrap' => false ] );See Output formats and escaping.
wpmcf_has_field
wpmcf_has_field( string $group_key, string $field_key, mixed $object = null, array $args = [] ): booltrue unless the value is null, '' or [] (0, '0' and false count as values).
if ( wpmcf_has_field( 'listing', 'gallery' ) ) { /* ... */ }wpmcf_update_field
wpmcf_update_field( string $group_key, string $field_key, mixed $value, mixed $object = null, array $args = [] ): boolValidates and sanitizes $value with the field type, writes it, purges page caches (posts). null clears. false for an unknown group/field, a missing object or invalid reference, a refused value (the old value is kept; this includes values that break the field's length, min/max or step rules) or a failed write. No capability check. $args: context, widget_*.
wpmcf_update_field( 'listing', 'price', 450000, $post_id );
wpmcf_update_field( 'profile', 'bio', 'Hello', 'user_3' );See Writing values.
wpmcf_delete_field
wpmcf_delete_field( string $group_key, string $field_key, mixed $object = null, array $args = [] ): boolClears the value. true when cleared or nothing to clear; false for an unknown group/field or invalid reference. No capability check.
wpmcf_delete_field( 'listing', 'price', $post_id );wpmcf_get_option_field
wpmcf_get_option_field( string $group_key, string $field_key, array $args = [] ): mixedRaw value on an options page (context fixed to options). $args: path, sub_key, default.
$name = wpmcf_get_option_field( 'site_settings', 'company_name' );wpmcf_the_option_field
wpmcf_the_option_field( string $group_key, string $field_key, array $args = [] ): voidEchoes the escaped options-page value. $args: format, wrap, path, sub_key, default.
wpmcf_the_option_field( 'site_settings', 'company_name', [ 'wrap' => false ] );wpmcf_has_option_field
wpmcf_has_option_field( string $group_key, string $field_key, array $args = [] ): boolTrue when the options-page value is not empty. $args: path, sub_key.
wpmcf_update_option_field
wpmcf_update_option_field( string $group_key, string $field_key, mixed $value ): boolWrites the shared options row. Fires wpmcf/options_pages/values_saved once per options page that shows the group. No capability check. Does not verify that the group belongs to an options page.
wpmcf_update_option_field( 'site_settings', 'hours', 40 );wpmcf_delete_option_field
wpmcf_delete_option_field( string $group_key, string $field_key ): boolClears the options-page value. No capability check.
wpmcf_check_password
wpmcf_check_password( string $group_key, string $field_key, string $password, mixed $object = null, array $args = [] ): boolTrue when $password matches the stored value of a top-level Password field (hashed, encrypted or plain). false for an empty field or password, a non-Password field or an unknown object.
if ( wpmcf_check_password( 'download', 'code', $typed, $post_id ) ) { /* allow */ }See Password helpers and security.
wpmcf_get_password
wpmcf_get_password( string $group_key, string $field_key, mixed $object = null, array $args = [] ): ?stringReadable value of an encrypted or plain Password field; null for a hashed one, an empty field or a failed read. Never print it.
$secret = wpmcf_get_password( 'integration', 'api_secret', 'option' );wpmcf_query_posts
wpmcf_query_posts( array $args ): arrayget_posts() with suppress_filters => false, so wpmcf_query, orderby wpmcf:group.field and wpmcf_distance work. Returns WP_Post[] (or IDs with 'fields' => 'ids'); an empty array when the query fails.
$posts = wpmcf_query_posts( [
'post_type' => 'listing',
'numberposts' => 10,
'wpmcf_query' => [ [ 'field' => 'listing.price', 'compare' => '<=', 'value' => 500 ] ],
'orderby' => [ 'wpmcf:listing.price' => 'ASC' ],
] );See Querying posts.
wpmcf_get_global
wpmcf_get_global( string $key, array $args = [] ): mixedRaw value of a Global Data variable (string). $args['default'] for a missing or empty variable. Resolves {{ }} expressions. Returns decrypted password variables.
$phone = wpmcf_get_global( 'phone', [ 'default' => '' ] );wpmcf_the_global
wpmcf_the_global( string $key, array $args = [] ): voidEchoes the escaped value in <span class="wpmcf-global-value">. $args: format, wrap. Resolves {{ }} expressions; default is printed for a missing or empty variable. Prints nothing for password variables unless wpmcf/global/the_password allows it.
wpmcf_the_global( 'phone', [ 'wrap' => false ] );wpmcf_has_global
wpmcf_has_global( string $key, array $args = [] ): boolTrue when the variable exists and is not empty ('0' counts as a value).
wpmcf_update_global
wpmcf_update_global( string $key, mixed $value ): boolSets an existing variable; scalar or null only; HTML tags are stripped; fires wpmcf/global_data/saved. false for an unknown key or non-scalar value. No capability check.
wpmcf_update_global( 'phone', '+90 212 555 00 00' );Internal helpers
These exist for the plugin and its integrations. They are not part of the stable API; use the functions above.
Function | Notes |
|---|---|
| The service behind the read/print functions. |
| The service behind the write functions. |
| The service behind the Global Data functions. |
| Turns an object reference into |
| Looks a service up in the container after boot. |
Other functions documented elsewhere
Function | Where |
|---|---|
| |
| Field groups (PHP-registered groups) |
|
ACF compatibility functions
After a migration from ACF, the plugin provides ACF's template functions for the migrated fields once ACF is deactivated: get_field(), the_field(), get_fields(), get_field_object(), the have_rows(), the_row() and get_sub_field() loops, update_field(), delete_field(), the [acf] shortcode and options-page reads. They exist only while the compatibility layer is active, and you should not use them in new code.
ACF function | Use instead |
|---|---|
|
|
|
|
|
|
|
|
|
|
Options-page reads |
|
Massbase › Tools › ACF lists every place in your theme and plugins that still calls an ACF function, with the replacement code. Walk through the rows to move the code over step by step.
Where the arguments are documented
Topic | Page |
|---|---|
Return values per type | |
Object references | |
| |
Shortcode attributes |
Still stuck? Contact support