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.
As of version 6.9, dynamic fields will only include data from submitted entries. Draft entries, in-progress entries, and abandoned entries will be ignored by default. Use this filter to modify the default behavior with support for the new options.
Usage
add_filter( 'frm_dynamic_field_include_drafts', 'dynamic_include_draft_entries' );
Parameters
- $include (string): Accepts exclude (default), include, and draft_only
- $args (array): Contains field (array)
Examples
Include draft entries only
Use this code snippet to only include data from draft entries.
add_filter( 'frm_dynamic_field_include_drafts', 'dynamic_include_draft_entries' );
function dynamic_include_draft_entries( $include ) {
return 'draft_only'; // Or return FrmProDynamicFieldsController::DRAFT_ONLY;
}
Include both drafts and submitted entries
Use this code snippet to include both draft and submitted entries.
add_filter( 'frm_dynamic_field_include_drafts', 'dynamic_include_entries' );
function dynamic_include_entries( $include ) {
return 'include'; // Or return FrmProDynamicFieldsController::INCLUDE_DRAFTS;
}
Include only draft entries for specific dynamic field
Use this code snippet to only include data from draft entries for a specific dynamic field.
add_filter( 'frm_dynamic_field_include_drafts', 'specific_dynamic_include_draft', 10, 2 );
function specific_dynamic_include_draft( $include, $args ) {
if ( 13 == $args['field']['id'] ) { // Replace 13 with the ID of the dynamic field
return 'draft_only'; // Or return FrmProDynamicFieldsController::DRAFT_ONLY;
}
return $include;
}
Include abandoned entries only
Use this code snippet to only include data from abandoned entries.
add_filter(
'frm_dynamic_field_include_drafts',
function() {
return FrmProDynamicFieldsController::ABANDONED_ONLY;
}
);
Include in-progress entries only
Use this code snippet to only include data from in-progress entries.
add_filter(
'frm_dynamic_field_include_drafts',
function() {
return FrmProDynamicFieldsController::IN_PROGRESS_ONLY;
}
);
Include all entries
Use this code snippet to include data from all entries.
add_filter(
'frm_dynamic_field_include_drafts',
function() {
return FrmProDynamicFieldsController::INCLUDE_ALL;
}
);