Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook can be used to prepare data when a new entry is being created via rest api request.
Usage
add_filter( 'frm_api_prepare_data', 'prepare_data' );
Parameters
- $data (array)
- $fields (array)
Examples
Prepare data
This example will allow you to execute different actions on the data according to the type of field
add_filter( 'frm_api_prepare_data', 'prepare_data' );
function prepare_data( $data, $fields ) {
foreach ( $fields as $k => $field ) {
switch ( $field->type ) {
case 'checkbox':
case 'select':
//do something
break;
case 'file':
//do something
break;
case 'date':
FrmAPIAppHelper::format_date( $field, $data['item_meta'][ $field->id ] );
}
}
return $data;
}