Created
June 16, 2017 12:19
-
-
Save greenhornet79/4baf41681c04295c6405e2013e094f08 to your computer and use it in GitHub Desktop.
Add custom fields to the Leaky Paywall subscriber table with filters
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_filter( 'leaky_paywall_subscribers_columns', 'zeen101_add_column_for_custom_field' ); | |
add_filter( 'manage_leaky_paywall_subscribers_custom_column', 'zeen101_add_data_to_custom_field_column', 10, 3 ); | |
function zeen101_add_column_for_custom_field( $columns ) { | |
$columns['zeen101_custom_field'] = 'Zeen101 Custom Field'; | |
return $columns; | |
} | |
function zeen101_add_data_to_custom_field_column( $content, $column_name, $user_id ) { | |
$settings = get_leaky_paywall_settings(); | |
$mode = 'off' === $settings['test_mode'] ? 'live' : 'test'; | |
$custom_field = get_user_meta( $user_id, '_issuem_leaky_paywall_' . $mode . '_zeen101_custom_field', true ); | |
if ( $custom_field ) { | |
return esc_attr( $custom_field ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment