BP_XProfile_Field_Type_Datebox::admin_save_settings( int $field_id, array $settings )
Save settings from the field edit screen in the Dashboard.
Description
Parameters
- $field_id
-
(int) (Required) ID of the field.
- $settings
-
(array) (Required) Array of settings.
Return
(bool) True on success.
Source
File: bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php
public function admin_save_settings( $field_id, $settings ) { $existing_settings = self::get_field_settings( $field_id ); $saved_settings = array(); foreach ( array_keys( $existing_settings ) as $setting ) { switch ( $setting ) { case 'range_relative_start' : case 'range_relative_end' : $op_key = $setting . '_type'; if ( isset( $settings[ $op_key ] ) && 'past' === $settings[ $op_key ] ) { $value = 0 - intval( $settings[ $setting ] ); } else { $value = intval( $settings[ $setting ] ); } $saved_settings[ $setting ] = $value; break; default : if ( isset( $settings[ $setting ] ) ) { $saved_settings[ $setting ] = $settings[ $setting ]; } break; } } // Sanitize and validate saved settings. $saved_settings = self::validate_settings( $saved_settings ); foreach ( $saved_settings as $setting_key => $setting_value ) { bp_xprofile_update_meta( $field_id, 'field', $setting_key, $setting_value ); } return true; }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.