acp/export/value

This Filter acp/export/value allows you to change the value for columns used in the export.

Usage

/**
 * @param string    $value
 * @param AC_Column $column
 * @param int       $post_id
 */
function acp_export_value( $value, $column, $post_id ) {

	// Check for a specific column to change it's value

	return $value;
}

add_filter( 'ac/export/value', 'acp_export_value', 10, 3 );

Examples

The following example changes the date format for all Custom Field columns with field type set to ‘Date’

/**
 * @param string    $value
 * @param AC_Column $column
 * @param int       $post_id
 */
function aca_export_custom_field_date_format( $value, $column, $post_id ) {

	// Check for the Custom Field Column
	if ( $column instanceof AC_Column_CustomField ) {

		if ( 'date' === $column->get_field_type() ) {

			if ( $timestamp = ac_helper()->date->strtotime( $value ) ) {
				$value = date( 'Y-m-d', $timestamp );
			}

		};

	}

	return $value;
}

add_filter( 'ac/export/value', 'aca_export_custom_field_date_format', 10, 3 );

The following example shows how you can make a third-party column exportable.

/**
 * @param string    $value
 * @param AC_Column $column
 * @param           $term_id
 *
 * @return string
 */
function aca_export_bbp_forum_role( $value, $column, $user_id ) {

	// You can inspect the table and search for the TH for the table. The id used for the TH is the the column type
	if ( 'bbp_user_role' == $column->get_type() ) {
		$value = bbp_get_user_role( $user_id );
	}

	return $value;
}

add_filter( 'ac/export/value', 'aca_export_bbp_forum_role', 10, 3 );