Snippets

Visser Labs Add a custom User field to the Orders export type

Created by Michael Visser
<?php
function custom_woo_ce_extend_order_fields( $fields ) {

	$fields[] = array(
		'name' => 'user_description',
		'label' => 'Biographical Info',
		'hover' => 'Custom User field within functions.php'
	);
	return $fields;

}
add_filter( 'woo_ce_order_fields', 'custom_woo_ce_extend_order_fields' );

function custom_woo_ce_extend_order( $order ) {

	if( !empty( $order->user_id ) ) {
		$user_data = get_userdata( $order->user_id );
		if( $user_data !== false ) {
			$order->user_description = $user_data->description;
		}
		unset( $user_data );
	}
	return $order;

}
add_filter( 'woo_ce_order', 'custom_woo_ce_extend_order' );
?>

Comments (0)