Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Created December 3, 2020 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/3cea51b4958a430389860fd63e5d8b6b to your computer and use it in GitHub Desktop.
Save zackkatz/3cea51b4958a430389860fd63e5d8b6b to your computer and use it in GitHub Desktop.
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