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 payment criteria

The free version of Post Pay Counter allows to pay authors for words, visits, comments and images with no further effort than setting up the appropriate payment values in the Options page. Further addons extend the basic payment criterias, with for example Adsense revenues, Facebook likes/shares/comments, single characters, referral visits, and many more.

However, what if you want to add your own custom payment criteria? In that case, Post Pay Counter has some handy functions that allow you do just that, with ease.

The class which contains payment types functions is called PPC_counting_types. It contains a method called register_counting_type, which accepts as input an array of parameters as detailed below. The ones in bold are compulsory.

  • id – unique identifier of the payment criteria (payment criteria are usually prefixed by a shortened version of the addon that registered them, for example ppc, ppcp, ppcp_fb…).
  • label – text that will be displayed in the stats table to refer to this payment criteria.
  • apply_to – whether the payment criteria applies to posts or authors (or both). Possible values are post , author, both.
  • settings_status_index – (optional) the name of the settings index of the plugin settings to check whether the payment criteria is enabled. (This method can only be used if the setting is stored among the default ones, in the same wp_option. Otherwise you will have to check the enabled status in another way.)
  • count_callback – (optional) method to count how many elements there are to be paid (eg. how many words, visits…).
    Needs to return an array in the form array( 'to_count' => int, 'real' => int ) .
    Can (and should) be a class method, in which case an array is needed (e.g. array( 'classname', 'static_method' ) or array( $object, 'method' ) ). In any case, it will receive the $post WP_Post_Object as parameter if apply_to == post; while it will receive author stats and author id if apply_to == author.
  • display – (optional) whether you want the count, the payment, both or nothing displayed in the stats table. Possible values are count, payment, both, none. Default is both.
  • payment_callback – method to compute payment of the result of count_callback. Will receive the counting output array as parameter.
  • other_params – (optional) extra information you may need to store in the payment criteria definition.
    • not_to_pay – (bool) exclude counting from payments (only affects PRO).

Note that this will only add a new column to the stats table, as well as in the confirm payment page and in payment history records. It will not, however, add a related settings section in the Options page: that you have to take care yourself. If you need to do it, look into ppc_meta_boxes_class.php for the frontend part, into ppc_ajax_functions_class.php for handling the AJAX communication between frontend and backend.

What follows is an example of registering a payment criteria, taken from the PRO version code. It adds a post payment criteria to allow awarding a custom bonus.


/**
 * Registers payment bonus payment criteria.
 *
 * Hooks to ppc_registered_built_in_counting_types - PPCP_payment_bonus::register_counting_type_payment_bonus
 */
static function register_counting_type_payment_bonus() {
  global $ppc_global_settings;

  $payment_bonus_counting_type = array(
    'id' => 'bonus',
    'label' => __( 'Bonus', 'ppcp' ),
    'apply_to' => 'post',
    'settings_status_index' => 'enable_payment_bonus',
    'display' => 'payment',
    'payment_only' => true,
    'count_callback' => array( 'PPCP_payment_bonus', 'get_post_payment_bonus_count' ),
    'payment_callback' => array( 'PPCP_payment_bonus', 'get_post_payment_bonus' )
  );

  $ppc_global_settings['counting_types_object']->register_counting_type( $payment_bonus_counting_type );
}

/**
 * Assigns payment.
 *
 * @access public
 * @param $countings array countings
 * @param $post_id int post id
 * @return object WP post
 */
static function get_post_payment_bonus( $countings, $post_id ) {
  global $ppcp_global_settings;

  $post_bonus = (float) get_post_meta( $post_id, 'ppcp_payment_bonus', true );
  return $post_bonus;
}
  • Was this Helpful ?
  • Yes   No
stats
What are your Feelings
Updated on April 12, 2022
Add a custom column to the stats table

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