Post Pay Counter

The best way to pay authors on WordPress

  • Features
    • PRO version
  • Cart
    • Addons
  • Documentation
  • Support

General

  • Pay writers per visit on WordPress
  • Shortcodes – Display stats in public pages
  • Define settings priority (user, role, category)
  • Pay per bbPress Topics and Replies
  • Caching features and stats snapshots
  • WP-CLI commands

Payment features

  • Payment features and PayPal payments
  • Setup an effective payment flow for lifetime visits
  • PayPal setup and configuration
  • Set users’ PayPal email address

Developer documentation

  • Add a custom payment criteria
  • Add a custom column to the stats table
  • Set users’ PayPal email address
  • Extract selected information from stats table
  • Handle massive Analytics data imports
  • Backup plugin data
  • Caching features and stats snapshots
  • Hide stats columns from BuddyPress Members page
  • WP-CLI commands

Analytics integration

  • Google Analytics setup and configuration
  • The future of Google Analytics integration and support for GA4
  • Matomo Analytics setup and configuration
  • Plausible Analytics setup and configuration
  • Migrate visits data away from Google Analytics
  • Share Google Adsense revenue with authors
  • Fix the “All Website Data” Analytics label issue
  • Handle massive Analytics data imports

Troubleshooting

  • Fixed a Publisher Bonus issue with complex settings setups
  • Issue with Publisher Bonus negative due payment
  • License activation failure with timeout error
  • Home
  • Docs
  • Developer documentation
  • Add a custom column to the stats table
Table of Contents
  • Custom column to general stats view
  • Custom column to author stats view

You might find yourself wanting to add an additional custom column to the stats table. Maybe you want to display some extra piece of information about authors in the general stats view (ex. their email, their employment status), or maybe you want to display extra information about posts in an author detailed view. Even though there is no native plugin’s function that will get the job done in just one function call, some light custom coding is enough.

Since stats are displayed in a table, all that we have to do is add a new column to it, and specify how it should be populated per each author/post.

Custom column to general stats view

If you want to append extra information to authors, the relevant WordPress hooks to use are:

  • the filter ppc_general_stats_format_stats_after_cols_default, to add the extra column to the header/footer of the stats table. It takes the current columns array as only parameter: add the new column and return the updated array;
  • the filter ppc_general_stats_each_field_empty_value, to populate the new column. It takes four parameters:
    • $field_value – current field value. Change this to the information you would like to display in this new column.
    • $column_name – the column that is being processed for this filter call. To avoid overwriting all other columns values, make sure to check that $column_name == new_col_name.
    • $author_stats – the full stats array for the current author.
    • $author_id – user ID of the author being processed.

In the following example, we add a custom column to display the user email address. We also show how to make additional checks on user’s permissions and page attributes.

add_filter( 'ppc_general_stats_format_stats_after_cols_default', 'ppc_add_email_col_html', 10 );
add_filter( 'ppc_general_stats_each_field_empty_value', 'ppc_email_td_html', 10, 4 );

/**
 * Adds custom field column to stats page.
 *
 * Hooks to PPC_HTML_functions::get_html_stats() - ppc_general_stats_html_cols_after_default.
 *
 * @param $cols array Stats columns
 */
function ppc_add_email_col_html( $cols ) {
    global $ppc_global_settings;

    //Only add column to general stats page
    if( $ppc_global_settings['current_page'] != 'stats_general' ) return $cols;

    $perm = new PPC_permissions();
    if( $perm->can_mark_as_paid() )
        $cols['author_email'] = __( 'Email', 'ppc' );

    return $cols;
}

/**
 * Populates custom field in stats page.
 *
 * Hooks to PPC_HTML_functions::get_html_stats() - ppc_general_stats_html_after_each_default.
 *
 * @param 	$author int author id
 * @param 	$formatted_data array formatted stats
 * @param 	$raw_data array sorted stats
 */
function ppc_email_td_html( $field_value, $column_name, $author_stats, $author_id ) {
    global $ppc_global_settings;

    //Only add column to general stats page
    if( $ppc_global_settings['current_page'] != 'stats_general' ) return $field_value;

    //Only populate the email column
    if( $column_name != 'author_email' ) return $field_value;
	
    $perm = new PPC_permissions();
    if( $perm->can_mark_as_paid() OR $perm->can_see_paypal_functions() ) {
        $user_data = get_userdata( $author_id );
        $author_email = $user_data->user_email;

        return $author_email;
    }

    return $field_value;
}

Custom column to author stats view

If you want to append extra information to posts, the relevant WordPress hooks to use are:

  • the filter ppc_detailed_stats_format_stats_after_cols_default, to add the extra column to the header/footer of the stats table. It takes the current columns array as only parameter: add the new column and return the updated array;
  • the filter ppc_detailed_stats_each_field_empty_value, to populate the new column. It takes four parameters:
    • $field_value – current field value. Change this to the information you would like to display in this new column.
    • $column_name – the column that is being processed for this filter call. To avoid overwriting all other columns values, make sure to check that $column_name == new_col_name.
    • $post_stats – the full stats array for the current post.
    • $post_id – ID of the post being processed.

In the following example we show how to add an extra column that displays the MD5 hash of the post title. Agreed: it is entirely useless, but we honestly think we have already included all information you might be looking for!

add_filter( 'ppc_general_stats_format_stats_after_cols_default', 'ppc_add_md5_title_col_html', 10 );
add_filter( 'ppc_general_stats_each_field_empty_value', 'ppc_md5_title_html', 10, 4 );

/**
 * Adds custom field column to stats page.
 *
 * Hooks to PPC_HTML_functions::get_html_stats() - ppc_author_stats_html_cols_after_default.
 *
 * @param $cols array Stats columns
 */
function ppc_add_md5_title_col_html( $cols ) {
    $cols['md5_title'] = __( 'MD5 Title', 'ppc' );
    return $cols;
}

/**
 * Populates custom field in stats page.
 *
 * Hooks to PPC_HTML_functions::get_html_stats() - ppc_author_stats_html_after_each_default.
 *
 * @param 	$author int author id
 * @param 	$formatted_data array formatted stats
 * @param 	$raw_data array sorted stats
 */
function ppc_md5_title_td_html( $field_value, $column_name, $post_stats, $author_id ) {
    global $ppc_global_settings;

    //Only populate the md5 title column
    if( $column_name == 'md5_title' ) 
        $field_value = md5($
return $field_value;
	
    $author_email = $user_data->user_email;

        return $author_email;
    }

    return $field_value;
}
  • Was this Helpful ?
  • Yes   No
stats
What are your Feelings
Updated on April 14, 2022
Add a custom payment criteriaSet users’ PayPal email address
Table of Contents
  • Custom column to general stats view
  • Custom column to author stats view

Copyright © 2025 · Centric Theme on Genesis Framework · WordPress · Log in