Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add Promotion Method to the Affiliates table in AffiliateWP
<?php
/**
* Add Promotion Method to AffiliateWP affiliates table columns
*
* @since December 3, 2020
*
* @param array $prepared_columns Prepared columns.
* @param array $columns The columns for this list table.
* @param \AffWP_Affiliates_Table $this List table instance.
*/
add_filter( 'affwp_affiliate_table_columns', function( $prepared_columns, $columns, $table ) {
$prepared_columns['promotion_method'] = __( 'Promotion Method', 'affiliate-wp' );
return $prepared_columns;
}, 10, 3 );
/**
* Add Promotion Method value to the new table column
*
* @since December 3, 2020
*
* @param string $value The column data.
* @param AffWP\Affiliate $affiliate The current affiliate object
*/
add_filter( 'affwp_affiliate_table_promotion_method', function( $value, $affiliate ) {
$promotion_method = get_user_meta( $affiliate->user_id, 'affwp_promotion_method', true );
return esc_html( $promotion_method );
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment