Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More โEnable accountability for discount management by tracking the author of every WooCommerce coupon. Save the creator ID using the woocommerce_new_coupon action and update_post_meta for long-term storage. Extend the WooCommerce admin table by adding a custom Creator column via the manage_edit-shop_coupon_columns filter. Implement sorting logic with pre_get_posts to allow administrators to filter coupons by specific staff members. This workflow is essential for multi-vendor stores or large e-commerce teams requiring audit trails for promotional activities and marketing performance tracking.
By default, WooCommerce doesn’t log the user who adds a coupon. But you can enable this using a simple code tweak to track and display the coupon's creator. Step 1: Open your theme’s functions.php or a custom plugin file. Step 2: Add the below code snippet:
// Save the creator ID
function save_coupon_creator($post_id) {
$user_id = get_current_user_id();
update_post_meta($post_id, 'coupon_creator', $user_id);
}
add_action('woocommerce_new_coupon', 'save_coupon_creator');
// Show creator on coupon edit
function display_coupon_creator($coupon) {
$creator_id = get_post_meta($coupon->get_id(), 'coupon_creator', true);
if ($creator_id) {
$name = get_the_author_meta('display_name', $creator_id);
echo 'Coupon Creator: ' . $name . '';
}
}
add_action('woocommerce_coupon_options_usage', 'display_coupon_creator');
To make this visible in your coupon list table, follow these steps: Step 1: Add this code to your theme/plugin:
// Add "Creator" column
function add_coupon_creator_column($columns) {
$columns['coupon_creator'] = __('Coupon Creator', 'domain');
return $columns;
}
add_filter('manage_edit-shop_coupon_columns', 'add_coupon_creator_column');
// Display name
function display_coupon_creator_column($column, $coupon_id) {
if ($column === 'coupon_creator') {
$id = get_post_meta($coupon_id, 'coupon_creator', true);
echo $id ? get_the_author_meta('display_name', $id) : '-';
}
}
add_action('manage_shop_coupon_posts_custom_column', 'display_coupon_creator_column', 10, 2);
// Make sortable
function make_coupon_creator_column_sortable($columns) {
$columns['coupon_creator'] = 'coupon_creator';
return $columns;
}
add_filter('manage_edit-shop_coupon_sortable_columns', 'make_coupon_creator_column_sortable');
// Add sorting logic
function modify_coupon_creator_column_sorting($query) {
if (is_admin() && $query->is_main_query() && $query->get('orderby') === 'coupon_creator') {
$query->set('meta_key', 'coupon_creator');
$query->set('orderby', 'meta_value_num');
}
}
add_action('pre_get_posts', 'modify_coupon_creator_column_sorting');
Now, your WooCommerce admin area shows and sorts coupons by their creator — helpful for accountability and user tracking. 
Search our archives or reach out to our team for solutions and expert advice.