Created
December 3, 2020 18:29
-
-
Save zackkatz/3cea51b4958a430389860fd63e5d8b6b to your computer and use it in GitHub Desktop.
Add Promotion Method to the Affiliates table in AffiliateWP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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