Filter
uncanny-automator-pro
automator_buddyboss_xprofile_field_is_date
Filters if a BuddyBoss Xprofile field is considered a date, allowing customization of date field detection.
add_filter( 'automator_buddyboss_xprofile_field_is_date', $callback, 10, 1 );
Description
Allows modification of the accepted BuddyBoss XProfile field types considered "date" by Uncanny Automator. Developers can add custom field types to be recognized as dates for Automator actions and triggers related to BuddyBoss profile data. Default includes 'datebox'.
Usage
add_filter( 'automator_buddyboss_xprofile_field_is_date', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Add custom date field types to Uncanny Automator's BuddyBoss integration.
*
* This filter allows developers to extend the list of field types that
* Uncanny Automator considers as date fields for BuddyBoss profile data.
* By default, only 'datebox' is recognized. This example adds 'datetimebox'
* as an additional date-related field type.
*
* @param array $date_field_types An array of field types considered as dates.
* @return array The modified array of date field types.
*/
add_filter(
'automator_buddyboss_xprofile_field_is_date',
function( $date_field_types ) {
// Add 'datetimebox' as another type of date field for BuddyBoss XProfile.
$date_field_types[] = 'datetimebox';
return $date_field_types;
},
10, // Priority: 10 (default)
1 // Accepted Args: 1 (the $date_field_types array)
);
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/buddyboss/actions/bdb-setuserprofiledata.php:183
private function maybe_format_field_value( $value, $field_id ) {
$field = xprofile_get_field( $field_id );
if ( ! is_a( $field, 'BP_XProfile_Field' ) ) {
return $value;
}
$is_array_type = apply_filters(
'automator_buddyboss_xprofile_field_is_array',
array(
'checkbox',
'multiselectbox',
'socialnetworks',
)
);
if ( in_array( $field->type, $is_array_type ) ) {
$value = ! is_array( $value ) ? explode( ',', $value ) : $value;
}
$is_date_type = apply_filters(
'automator_buddyboss_xprofile_field_is_date',
array(
'datebox',
)
);
// Date field.
if ( in_array( $field->type, $is_date_type ) ) {
// Check if value is a valid date.
if ( strtotime( $value ) ) {
// Check if time is set, if not set it to 00:00:00
$date = new DateTime( $value );
if ( $date->format( 'H:i:s' ) == '00:00:00' ) {
$value = $date->format( 'Y-m-d 00:00:00' );
} else {
$value = $date->format( 'Y-m-d H:i:s' );
}
}
}
return $value;
}