This documentation is deprecated since Admin Columns version 4.
Please view the updated version of this documentation here.

Filter cac/inline-edit/ajax-column-save/value for changing the value before storing it to the database.

Usage

/**
 * Filter for changing the value before storing it to the DB
 *
 * @param mixed $value Value send from inline edit ajax callback
 * @param object CPAC_Column instance
 * @param int $id ID
 */
function my_cac_editable_ajax_column_save_value( $value, $column, $id ) {

	// Possibly modify $value

	return $value;
}
add_filter( 'cac/inline-edit/ajax-column-save/value', 'my_cac_editable_ajax_column_save_value', 10, 3 );

Example

In this example we are storing a date in a timestamp format, instead of the ‘YYYYMMDD’ format, for a Custom Field type column. Because the datepicker will always use the dateformat ‘YYYYMMDD’, we will convert this into a timestamp¬†with the filter cac/inline-edit/ajax-column-save/value.

/**
 * Inline Edit: Changes custom field date format from YYYYMMDD to a timestamp when saving
 *
 */
function my_set_custom_field_date_store_format( $value, $column, $id ) {
	$column_type = 'column-meta';  // enter type of field. You can find this by hovering of the Type label of the column settings.
	$custom_field_type = 'date'; // enter type of custom field. You can find this by hovering of the Type label of the custom "Field Type" settings.
	if ( $column_type == $column->get_type() && $custom_field_type == $column->get_field_type() ) {
		$value = $column->get_timestamp( $value ); // convert to timestamp
	}
	return $value;
}
add_filter( 'cac/inline-edit/ajax-column-save/value', 'my_set_custom_field_date_store_format', 10, 3 );