Developer’s Custom Fields documentation
Developer’s Custom Fields is a plugin for WordPress. It’s designed to give developers (usually, custom theme developers) tools that make it easy to manage custom fields (a.k.a. metadata) for any post type (including media attachments) and for user profiles.
For Installation, Getting Started, and Changelog, see the plugin page on wordpress.org.
Development code is hosted on GitHub. Please find issue tracking there too.
This documentation is for version 0.8.2.
Configuration
Constants
Some defaults will be overridden if the relevant constant is defined in wp-config.php.
- SLT_CF_USE_GMAPS (boolean) (default:
true) - If set to
false, disables all Google Maps functionality. - SLT_CF_USE_FILE_SELECT (boolean) (default:
true) - If set to
false, disables thefilefield type functionality. - prefix (string) (default:
'_slt_') - To avoid clashes with other plugins, all custom fields are stored in the database with a prefix on the key name. An underscore at the start means these values won’t show up in the default WordPress custom fields meta box. If you want to use a different prefix, set it at the start of your theme’s
functions.phpbefore you start using any custom fields, and never change it! - hide_default_custom_meta_box (boolean) (default:
true) - Whether or not to hide the default custom fields meta box on post edit screens.
- css_url (string)
- The URL of a stylesheet file to override the built-in
slt-cf-admin.cssstylesheet. - datepicker_css_url (string) (DEPRECATED)
- Former key for
ui_css_url - ui_css_url (string)
- The URL of a stylesheet file to override the built-in theme for the jQuery date and time components (Smoothness).
- datepicker_default_format (string) (default:
'dd/mm/yy') - The default format for the jQuery datepicker. For available formats, see http://docs.jquery.com/UI/Datepicker/formatDate. This can be overridden for particular fields. NOTE: Change this to
yy/mm/ddif you want to be able to easily sort by date fields! - timepicker_default_format (string) (default:
'hh:mm tt') - The default format for the jQuery timepicker. For available formats, see http://trentrichardson.com/examples/timepicker/. This can be overridden for particular fields.
- timepicker_default_ampm (boolean) (default:
false) - The default setting for the jQuery timepicker hour format. Set to
trueuses 12-hour format;falseuses 24-hour format. This can be overridden for particular fields. - $key (string) (required)
- The key of the setting you want to update
- $value (mixed) (required)
- The value you want to set the setting to
- type ( string | array ) (required) (
'post'|'user'|'attachment') - The type of box, i.e. which type of object its fields are applied to. Field-specific refinement of this is given by each field’s
scopeparameter (see below). You can pass multiple values in an array. - id (string) (required)
- A unique ID for the box.
- title (string) (required)
- A title for the box.
- description (string) (optional)
- A description for the box.
- context (string) (optional) (
'normal'|'advanced'|'side'|'above-content') (default:'advanced') - The context for boxes on post edit screens, i.e. where on the edit screen it appears. A special value,
above-content, will place the box using thenormalsetting in theadd_meta_boxfunction, but then use jQuery to place it above the content editor. - priority (string) (optional) (
'low'|'default'|'high') (default:'default') - On post edit screens, this governs how high up within the box’s context it will appear.
- fields (array) (required)
- The field definitions for this box.
- name (string) (required)
- A unique name for the field.
- label (string) (required)
- A label for the field. For multiple checkboxes and radio buttons, this label is actually for the legend element; each input’s label is created from the specified options.
- type (string) (optional) (
'text'|'textarea'|'textile'|'wysiwyg'|'select'|'file'|'radio'|'checkbox'|'checkboxes'|'date'|'time'|'datetime'|'gmap'|'notice') (default:'text') - The type of input for the field.
- File uploads are currently not allowed for user profiles or attachments.
- Before WordPress 3.5, attachments can only accept text and select types. For 3.5 and above, attachments can accept all types except
file. - The
noticefield type isn’t an actual form field; just use thedescriptionparameter to output a notice to the user.
- scope (array) (required)
- The box’s
typeparameter defines whether the box will appear for posts, users, or attachments (see above). Thisscopeparameter further refines which fields will appear in the box for any given edit screen.- For fields in post meta boxes, the scope defines which post type(s) the field should apply to, e.g.
array( 'post', 'page' ). - To apply to posts (of any type) assigned to terms in a taxonomy, pass the taxonomy name as the key, with an array of term names as the value, e.g.
array( 'category' => array( 'A Category' ) ). - To apply to pages associated with particular templates, use
array( 'template' => array( 'page_template.php' ) ). - For fields in user profiles, the scope defines which user role(s) the field should apply to, e.g.
array( 'adminstrator', 'editor' ). - For fields for attachments, the scope can define the MIME types the field should apply to, e.g.
array( 'image/png', 'image/jpeg', 'image/gif' )(pass an empty array to apply to all attachments). - To apply to particular posts, users or attachments by ID, use something like
array( 'posts' => array( 49, 66 ) ). - To exclude particular posts or attachments, add
'except_posts' => array( 67, 42 )to the array. - There’s also an
except_usersoption to exclude particular users.
- For fields in post meta boxes, the scope defines which post type(s) the field should apply to, e.g.
- label_layout (string) (optional) (
'block'|'inline') (default:'block') - How to position the label in relation to the input.
- ‘block’ puts the label on its own line above the input.
- For text, file uploads and selects, ‘inline’ will put the input on the same line as the label.
- Textarea and WYSIWYG fields always have ‘block’ labels; single checkboxes always have ‘inline’ labels.
- hide_label (boolean) (optional) (default:
false) - Whether to hide the label. Use with care!
- file_button_label (string) (optional) (default:
'Select file') - A label for the button in when field type is
file. - file_removeable (boolean) (optional) (default:
true) - For
filefields, this signals whether to include a checkbox to remove the file from the field. - input_prefix (string) (optional)
- A prefix to place before the input. Only applicable to text and single-choice select fields.
- input_suffix (string) (optional)
- A suffix to place after the input. Only applicable to text and single-choice select fields.
- description (string) (optional)
- A description for the field.
- default (mixed) (optional)
- Default value(s) for the field. For multiple select inputs and checkboxes, this should be an array of values. For
gmapfields, it should also be an array, with the following keys:centre_latlng,zoom,marker_latlng. - multiple (boolean) (optional) (default:
false) - For select inputs, whether the select should allow multiple values.
- options_type (string) (optional) (
'static'|'posts'|'users'|'terms') (default:'static') - For multiple select inputs and checkboxes, what type of options are being supplied.
- ‘static’ means you need to supply the options
- ‘posts’ means the input will be populated with the results of a
WP_Queryquery - ‘users’ means the input will be populated with users
- ‘terms’ means the input will be populated with taxonomy terms
- options (array) (optional)
- For ‘static’ options type fields (see above), an array of option values.
- The format should be:
array( 'Field label 1' => 'Field value 1', 'Field label 2' => 'Field value 2' ). - Option groups for select inputs are supported; include entries in the array like this:
array( 'Option group label' => '[optgroup]' ).
- The format should be:
- options_query (array) (optional) (default for posts:
array( 'posts_per_page' => -1 ); default for users:array()) - The query parameters when
options_typeisn’t ‘static’.- For ‘posts’ option type fields, this value is passed to
WP_Queryto populate the options. - For ‘users’ option type fields, this should be an array of roles from which users are selected; an empty value means all users.
- For ‘terms’ option type field, this should be an array that will be passed as the
$argsparameter of a call toget_terms. Ataxonomieskey should be included in the array – it will be extracted and passed as the$taxonomiesparameter forget_terms, e.g.'options_query' => ( 'taxonomies' => 'category', 'hide_empty' => false ). - Dynamic placeholders can also be used: see Option Query Placeholders.
- For ‘posts’ option type fields, this value is passed to
- no_options (string) (optional) (default:
'No options to choose from.') - Text to display if there’s no options returned for populating the field.
- exclude_current (boolean) (optional) (default:
true) - For posts and users options queries, whether to exclude the object being edited from the options.
- single (boolean) (optional) (default:
true) - For fields that have multiple values (e.g. multiple checkboxes and selects), setting this to
falsewill create multiple fields in thepostmetatable, instead of storing a serialized array of values in one field. This allows for more flexible use of themeta_queryparameter for queries. When you grab this kind of field with all other fields usingslt_cf_all_field_values, remember to pass this field’s key in the$multiple_fieldsarray. - required (boolean) (optional) (default:
false) - Currently only relevant for non-static options type fields. By default, an empty option will be included to allow no option to be selected. The empty option will use the
empty_option_textvalue. - empty_option_text (string) (optional) (default:
'[None]') - If
requiredis false, this is the text used for the empty option. - group_options (boolean) (default:
false) - For non-static option types, setting this to true means the items will be grouped, e.g. for users, by role; for posts, by category.
- width (integer) (optional)
- A width in em units for the input. For the
gmapfield type, the unit is pixels. - height (integer) (optional)
- A height in em units for the input. For the
gmapfield type, the unit is pixels. - capabilities (array) (optional) (default for posts:
array( 'edit_posts' ); default for users:array( 'edit_users' )) - The capabilities define which capabilities allow a user to manage this field. The field will appear for a user who has any of the capabilities given.
- edit_on_profile (boolean) (optional) (default:
false) - If this is set to
truefor a user field, even if the logged in user doesn’t have the capability to edit the field (as defined bycapabilities), they will be able to edit this field on their own profile. Ifcapabilitiesis passed an empty array and this is set to true, the field will only be editable by anyone for themselves, on their profile. - charcounter (boolean) (optional) (default:
false) - For textarea and textile fields, whether a JavaScript character counter should appear.
- allowtags (array) (optional) (DEPRECATED)
- For text and textarea field types, this array can specify HTML tags to be allowed, e.g.
array( 'a', 'em', 'strong' ). By default, all tags are stripped. Note: as of version 0.7.2 of this plugin, theallowed_htmlparameter should be used instead of this. - allowed_html (array) (optional)
- For text, textarea and WYSIWYG field types, this array can specify HTML tags to be allowed. The array is passed to
wp_kses(), and it should follow the format for its$allowed_htmlparameter, e.g.array( 'p' => array(), 'a' => array( 'href', 'title' ) ). By default, if the user does not have theunfiltered_htmlcapability, all tags are stripped from text and texarea fields; for WYSIWYG fields, the default allowed HTML is take from the WordPress$allowedposttagsvariable (see Otto’s post). If the user has theunfiltered_htmlcapability, and nothing is passed for this parameter, nothing is stripped. - autop (boolean) (optional) (default:
false) - For textarea and textile fields, whether to automatically add paragraph and line break tags.
- wysiwyg_settings (array) (optional) (default:
array( 'teeny' => true, 'media_buttons' => false )) - For WYSIWYG fields (WordPress 3.3+ only), this array is passed as the
$settingsto thewp_editorfunction. See WP source for details. - preview_size (string) (
'thumbnail'|'medium'|'large'|'full') (optional) (default:'medium') - For file uploads, this specifies the size of image that should be shown when an image has been uploaded.
- datepicker_format (string) (optional) (default:
datepicker_default_format) - The format for the jQuery datepicker. For available formats, see http://docs.jquery.com/UI/Datepicker/formatDate. Note that if you’re going to order queries by this field, you’ll need to format accordingly, e.g.
yy/mm/dd. - timepicker_format (string) (optional) (default:
timepicker_default_format) - The format for the jQuery timepicker. For available formats, see http://trentrichardson.com/examples/timepicker/.
- timepicker_ampm (string) (optional) (default:
timepicker_default_ampm) - The jQuery timepicker hour format. Set to
trueuses 12-hour format;falseuses 24-hour format. - location_marker (boolean) (optional) (default:
true) - For
gmapfields, this flag signals whether or not a marker can be placed to pinpoint a location. - gmap_type (string) (optional) (
'hybrid'|'roadmap'|'satellite'|'terrain') (default:'roadmap') - For
gmapfields, sets the initial map view type. - $key (string) (required)
- The key of the field. The prefix is added automatically.
- $type (string) (optional) (
'post'|'user') (default:'post') - The type of object this field applies to.
- $id
- (integer) (optional) – The ID of the object this field applies to. When
$typeis set to ‘post’, this defaults to the current post ID. - $before (string) (optional) (default:
'') - Some text or HTML to prepend to the value. Only included if there is a value to return.
- $after (string) (optional) (default:
'') - Some text or HTML to append to the value. Only included if there is a value to return.
- $echo (boolean) (optional) (default:
false) - Whether to echo or return the value.
- $single (boolean) (optional) (default:
true) - Set this to false when the field has been defined with
singleset to false. - $type (string) (optional) (
'post'|'user'|'attachment') (default:'post') - The type of object.
- $id (integer) (optional)
- The ID of the object. When
$typeis set to ‘post’, this defaults to the current post ID. - $multiple_fields (array) (optional)
- Keys for all the fields that are stored in multiple meta table fields, and should be returned as arrays. This is usually when you’ve set the
$singleparameter for a field tofalse. - $key (string) (required)
- The key to put the prefix on.
- $object_type (string) (optional) (
'post'|'user'|'attachment') (default:'post') - The object type. It’s only really important to pass this when the object is an attachment, because attachments get the leading underscore stripped from the prefix.
- $date_string (string) (required)
- The date string to reverse.
- $sep (string) (optional) (default:
'/') - The separator character.
- $to_timestamp (boolean) (optional) (default:
false) - Whether to return a timestamp or not.
- $key (string) (required)
- The key of the custom field to sort by first (prefix not needed).
- $query (array) (optional) (default:
array()) - The
WP_Queryparameters, as per http://codex.wordpress.org/Function_Reference/WP_Query#Parameters – including the second lot of ordering parameters. - $custom_order (string) (optional) (
'ASC'|'DESC') (default:'DESC') - The
ordervalue for the custom field ordering. - $numeric (boolean) (optional) (default:
false) - Set to
trueif the custom field value to be ordered by is numeric. - $object_type (string) (optional) (
'post'|'attachment') (default:'post') - The… er… object type.
- $type (string) (optional) (
'output'|'input') (default:'output') - Whether the map is for display or for use in a form.
- $name (string) (optional) (default:
'gmap_{count}') - For
inputtype maps, a name used as a base for the hidden input field names; foroutputtype maps, this is used as based for the ID of the map container (it will be$name_map_container). - $values (mixed) (optional) (default:
'stored_data') - Pass the default or current values as an array. The array keys, representing the values stored by the map, are:
centre_latlng(the latitude and longitude values for the map’s centre, comma-separated)zoom(the zoom level)marker_latlng(the latitude and longitude values for the location marker).- If this is set to
stored_data, the function will attempt to get values from the current post / user metadata.
- $width (integer) (optional) (default:
500) - Map width in pixels.
- $height (integer) (optional) (default:
300) - Map height in pixels.
- $location_marker (boolean) (optional) (default:
true) - Whether or not to use a location marker.
- $map_type_id (string) (optional) (
'hybrid'|'roadmap'|'satellite'|'terrain') (default:'roadmap') - Sets the initial map view type.
- $echo (boolean) (optional) (default:
true) - Whether to echo or return the generated output.
- $js_callback (string) (optional) (default:
'') - If given, this will be the name of a JavaScript function to be called once the map has been written to the page. The callback will be passed a reference to the Google Map object.
- $required (boolean) (optional) (default:
true) - For maps in a form (type = ‘input’), if this is set to false, a checkbox will be included, unchecked by default, controlling whether or not to use the map.
- $object_type (string) (optional) (
'post'|'user'|'custom') (default:'post') - If you’re not outputting a map related to a post object, make sure you set this. The ‘custom’ setting should be used if the map isn’t object-related, e.g. it’s a map created as part of theme options.
- $name (string) (required)
- The name for the field containing the file’s ID.
- $value (string) (required)
- The current value of the field.
- $label (string) (optional) (default:
'Select file') - A label for the button.
- $preview_size (string) (optional) (default:
'thumbnail') - The size for the preview of images.
- $removable (boolean) (optional) (default:
true) - Should there be a checkbox allowing users to remove the selected file from the field?
- name (string) (default: value set for the first map field)
- The name of the map field to use. By default, the first map field set for the post will be used.
- width (integer) (default: value set for the map field)
- Width in pixels.
- height (integer) (default: value set for the map field)
- Height in pixels.
- [OBJECT_ID]
- Replaced with the ID of the object currently being edited
- [TERM_IDS]
- Replaced with the IDs of terms from the specified taxonomy that are associated with the current object. It’s assumed that this will be used as the value for the terms parameter within the
tax_queryparameter; the taxonomy will be read from that array. - $scope_match (boolean)
- The current value of the scope match test (usually false).
- $request_type (string)
- The type of the current admin request, e.g. ‘post’ for any type of post editing or ‘user’ for editing a user profile.
- $scope (string)
- The scope of the current request, e.g. the post type or user’s role.
- $object_id (integer)
- The ID of the post or user being edited.
- $scope_key (mixed)
- The key of the scope being checked.
- $scope_value (mixed)
- The value of the scope being checked.
- $field (array)
- The settings for the field being checked.
- $options (array)
- The current array of options (usually empty).
- $request_type (string)
- The type of the current admin request, e.g. ‘post’ for any type of post editing or ‘user’ for editing a user profile.
- $scope (string)
- The scope of the current request, e.g. the post type or user’s role.
- $object_id (integer)
- The ID of the post or user being edited.
- $field (array)
- The array of settings for the field being checked.
- $default (mixed)
- The pre-defined default value.
- $request_type (string)
- The type of the current admin request, e.g. ‘post’ for any type of post editing or ‘user’ for editing a user profile.
- $object_id (integer)
- The ID of the post or user being edited.
- $object (object)
- The entire object being edited.
- $field (array)
- The array of settings for the field being saved.
- $value (mixed)
- The field value.
- $request_type (string)
- The type of the current admin request, e.g. ‘post’ for any type of post editing or ‘user’ for editing a user profile.
- $object_id (integer)
- The ID of the post or user being edited.
- $object (object)
- The entire object being edited.
- $field (array)
- The array of settings for the field being saved.
- $check (null)
- Passed in as default return value.
- $key (string)
- The key of the field to be checked.
- $type (string)
- The type of field, i.e. ‘post’, ‘attachment’ or ‘user’.
- $id (integer)
- The ID of the post or user whose field is being checked.
- $before (string)
- Text to go before the value.
- $after (string)
- Text to go after the value.
- $echo (boolean)
- Whether to echo or not.
- $single (boolean)
- If the field is being stored as a single meta field or multiple.
- $check (null)
- Passed in as default return value.
- $key (string)
- The key of the field to be checked.
- $type (string)
- The type of field, i.e. ‘post’, ‘attachment’ or ‘user’.
- $id (integer)
- The ID of the post or user whose field is being checked.
- Make the field
scopeoptional, default to “all”, i.e. an array populated with all post types, user roles, etc. - More targetted script / CSS inclusion
- GMap output for users? Default object ID for users is current user – doesn’t work for user profile front-end output
- Proper errors for missing ‘type’ parameter for boxes
- A
reciprocalflag for fields. That is, if a field on post edit screens allows the selection of users, and thereciprocalflag is set, user profiles would automatically allow selection of the posts they’re attached to. - Add support for multiple values for the same field (underway but stalled – called ‘cloning’)
- Extend use of
requiredfield setting to enforce validation of field entries - The capabilities system could be improved. Currently, if a field applies to a post type and a user role, you have to supply capabilities to edit that post type and to edit users for the capabilities check; if the user has either, they’ll be able to use that field. Should capabilities be more closely related to corresponding items in the scope array?
- Add more hooks?
- More control over TinyMCE, removing irrelevant buttons, etc.
- File uploads for user profiles – how to ‘attach’ media library items to users?
- Add validation mechanisms
slt_cf_field_valueto handle echoing non-string values?- Parameters to apply content filters / parse shortcodes from
slt_cf_field_value?
If for some reason you can’t define these in wp-config.php, just create a simple plugin file to put them in, and name the plugin with something beginning with “A”. Then it’ll load before this plugin with the constants defined.
Settings
By design, this plugin has no settings page. To change any of the default settings, use slt_cf_setting to set the following keys to the required values. (See Functions for syntax.)
Functions
Settings
<?php slt_cf_setting( $key, $value ); ?>
Run this function on the init action. NOTE: Since version 0.8, the function attached to the init action that contains this function must be set to lower than normal priority, i.e. 11 or higher, to ensure proper functioning for all settings.
See Configuration for the various settings.
Registering boxes and fields
<?php slt_cf_register_box( $box ); ?>
Run this function on the init action.
$box is an array of values defining the box:
The fields array should contain an array for each field, defining the following values:
Retrieving values
<?php slt_cf_field_value( $key [, $type, $id, $before, $after, $echo, $single ] ); ?>
<?php slt_cf_all_field_values( [ $type, $id, $multiple_fields ] ); ?>
<?php slt_cf_field_key( $key[, $object_type ] ); ?>
<?php slt_cf_reverse_date( $date_string[, $sep, $to_timestamp ] ); ?>
If you’ve set the format for a date field to yy/mm/dd, to enable easy sorting, when you output the date you can use this function to reverse it. It optionally returns a timestamp for alternative formatting using date:
Other useful functions
<?php slt_cf_get_posts_by_custom_first( $key [, $query, $custom_order, $numeric, $object_type] ); ?>
NOTE: This function currently doesn’t work. Probably needs a new approach. Let me know if you have one!
This function gets posts, but sorts first by the specified custom field key, then by a standard WordPress field.
Google maps
<?php slt_cf_gmap( $type = 'output', $name = 'gmap', $values = 'stored_data', $width = 500, $height = 300, $location_marker = true, $map_type_id = 'roadmap', $echo = true, $js_callback = '', $required = true ); ?>
This function outputs a Google Map, for display or for use in a form. It’s used internally, but is also designed to be leveraged by theme code or by other plugins.
For input maps, when the form is submitted, $_POST[$name] will be an array containing the values set by the manipulation of the map, with keys corresponding to the values detailed above.
File selection
<?php slt_cf_file_select_button( $name, $value, $label = 'Select file', $preview_size = 'thumbnail', $removable = true ); ?>
This function inserts a file select field, which includes a button to open the Media Library overlay, an optional ‘Remove’ checkbox, a hidden field containing the file’s ID, and a preview where appropriate. It’s used internally, but is also designed to be leveraged by theme code or by other plugins.
Shortcodes
[slt-cf-gmap]
This shortcode, when used in a post’s content, will display the map (if available) for that post. You can use the following optional attributes:
The map container generated will have the ID {$name}_map_container.
Option query placeholders
Sometimes you want to pass data to queries that is only available at runtime. For instance, you might want a field to be populated with posts, via the options_query parameter, that are selected according to another custom field which contains post IDs.
The following placeholders can be used in option queries:
So, say you have issue and article as custom post types for an online magazine. Each article is associated with an issue, and you want to define a field to set to set the “featured article” when editing an issue. You’d use something like this:
slt_cf_register_box( array(
'type' => 'post',
'title' => 'Featured article',
'id' => 'featured-box',
'context' => 'normal',
'fields' => array(
array(
'name' => 'featured',
'label' => 'Featured article',
'hide_label' => true,
'type' => 'select',
'options_type' => 'posts',
'options_query' => array(
'posts_per_page' => -1,
'post_type' => 'article',
'meta_key' => slt_cf_field_key('article-issue'),
'meta_value' => '[OBJECT_ID]'
),
'scope' => array( 'issue' ),
'capabilities' => array( 'edit_pages' )
)
)
));
This field would be populated by all articles where the article-issue field (indicating which issue the article is assigned to) is set to the ID of the issue currently being edited.
Hooks
The plugin provides various hooks to let developers extend its functionality without hacking the plugin code.
slt_cf_init (action)
A generic hook, mostly for dependent plugins to hook to – see: http://core.trac.wordpress.org/ticket/11308#comment:7
slt_cf_pre_save (action)
Run just before the custom field is saved.
slt_cf_init_boxes (filter)
This is applied to the registered boxes array after it’s been initialized. Should return the (possibly modified) boxes array.
slt_cf_check_scope (filter)
Run when none of the built-in scope checks matches. Should return a boolean value which determines whether the scope check has passed or not. These arguments are passed to help decide on the scope check outcome:
Example:
add_action( 'slt_cf_check_scope', 'my_scope_check', 10, 7 );
function my_scope_check( $scope_match, $request_type, $scope, $object_id, $scope_key, $scope_value, $field ) {
// This example will make sure fields with a 'global' scope apply everywhere the containing box appears
if ( $scope_key == 'global' )
$scope_match = true;
return $scope_match;
}
slt_cf_populate_options (filter)
Run when none of the built-in option types match. Should return an array of options for select, checkboxes, radios, etc., in the same format as described for the options passed when options_type is ‘static’. These arguments are passed to help decide on how to populate the options:
slt_cf_default_value (filter)
Filters the default value for fields. This allows more flexibility. As slt_cf_register_box is usually hooked to init, often useful information—like get_post_type() isn’t available at that point. Using this filter, defaults can be set at ‘runtime’.
slt_cf_pre_save_value (filter)
Run just before the custom field value is saved. Should return the possibly modified value. These arguments are passed:
Example:
add_action( 'slt_cf_pre_save_value', 'my_value_filter', 10, 5 );
function my_value_filter( $value, $request_type, $object_id, $object, $field ) {
// This example will make sure the 'important-notice' field has 'IMPORTANT!' prepended
if ( $field['name'] == 'important-notice' && $value && substr( $value, 0, 10 ) != 'IMPORTANT!' )
$value = 'IMPORTANT! ' . $value;
return $value;
}
slt_cf_field_value (filter)
Run at the start of the slt_cf_field_value() function. Allows this function’s action to be intercepted. Return something non-null to have that returned instead of the function proceeding; return null to let it proceed. These arguments are passed:
slt_cf_field_exists (filter)
Run at the start of the slt_cf_field_exists() function. Allows this function’s decision to be intercepted. Return something true or false to have that returned instead of the function proceeding; return null to let it proceed. These arguments are passed: