Post Pay Counter

The best way to pay authors on WordPress

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

How to define settings priority (user, category, role)

January 18, 2022 by Stefano 2 Comments

Post Pay Counter allows quite a fine-grained settings control. By itself, the free version allows to assign different settings to different users, while addons allow to define special settings for given user roles, categories, and post types.

What happens, though, if you have multiple settings addons active? What settings will actually be used for a post that belongs to a category with special settings, written by an author belonging to a user role with special settings?

The default settings priority is defined as follows:

  1. User settings
  2. Category settings
  3. User role settings
  4. General settings

The ordering of points 1 and 4 cannot be altered: user settings will always have the highest priority, while general settings will always be the final fallback if nothing more special is found. However, Points 2 and 3 can be exchanged. This can be achieved with the following lines of code to be pasted in your theme functions.php (or any similar file).

To enforce the ordering above, with category settings having a higher priority over role settings, use this code:

# Category settings come first
add_action( 'PPC_URCS_settings_priority', function( $priority ) { return 8; } );
add_action( 'PPC_CCS_settings_priority', function( $priority ) { return 9; } );

To enforce the opposite ordering, with role settings having a higher priority over category settings, use this code:

# User role settings come first
add_action( 'PPC_URCS_settings_priority', function( $priority ) { return 9; } );
add_action( 'PPC_CCS_settings_priority', function( $priority ) { return 8; } );

(The Post Type Custom Settings addon is not compatible with the other addons. They can still be used all together, but in case of a settings clash, there is no way, as of now, to control the behavior.)

Filed Under: Developer documentation, Tutorials Tagged With: settings

How to handle massive Analytics data imports

April 4, 2021 by Stefano Leave a Comment

Massive Analytics imports are possible with WP-CLI commands from the console, but there are still some limits even with them. Specifically, it looks like Google limits to 1 million rows the amount of results one can obtain in one request. If your site has a low of pages, and it is likely that the number of URLs for which Analytics has logged visits for the time range you requested exceeds 1 million, then the dataset Post Pay Counter will import will be incomplete. This can be noticed if the number of pending rows after the request is exactly 1 million.

To circumvent this, one can run multiple requests for shorter timeranges and let the plugin merge the data all together. The following bash script will for example import data from 2018-01-01 to 2021-12-31.

sudo -u www-data wp ppc ga clear
for year in {2018..2021}
do
  for month in {1..12}
  do
    lastday=$(date -d "$month/1 + 1 month - 1 day" "+%d") #https://stackoverflow.com/questions/12381501/how-to-use-bash-to-get-the-last-day-of-each-month-for-the-current-year-without-u
    sudo -u www-data wp ppc ga import --time-start="$year-$month-01" --time-end="$year-$month-$lastday"
    sudo -u www-data wp ppc ga process
  done
done

Filed Under: Developer documentation, Tutorials Tagged With: google analytics, wp-cli

WP-CLI commands

March 29, 2021 by Stefano Leave a Comment

Post Pay Counter and its addons come with some WP-CLI commands that can be executed from the terminal, especially for demanding tasks. These are useful when one wants to schedule them off peak hours, or when they are too heavy to execute through the web interface without timing out.

There is sufficient documentation in each of them: this is just a list with brief descriptions. Notice that commands that need to write files might need to be run as a different user (i.e. the one owning the plugin directory, most often www-data): use sudo su -u www-data wp [COMMAND].

Post Pay Counter WP-CLI commands

  • wp ppc stats: generates stats for given time range and author, particularly helpful to cache stats. Check out PPC caching features for details and examples.
  • wp ppc ga clear: clear current Analytics data and temp files.
  • wp ppc ga import: retrieves Analytics data for a given time range and stores it in temp files for further processing. This is equivalent to using the feature Settings > Google Analytics Status > Update data. Does not clear data, so if you want to erase current data, wp ppc ga clear is also needed beforehand.
    An import run from WP-CLI expects to be processed from WP-CLI as well.
    For massive Analytics imports, see here.
  • wp ppc ga process: processes pending Analytics rows, as it would happen from regular wp-admin refreshes when there are pending rows. No batching as in wp-admin though: it will instead process them all sequentially.
  • wp ppc ga incremental-update: performs the daily incremental Analytics data update, consisting of both gathering data and processing them.

Filed Under: Developer documentation, Tutorials Tagged With: terminal, wp-cli

Extracting selected information from stats table

May 19, 2020 by Stefano 1 Comment

Post Pay Counter already displays payment information nicely in the stats table by default, and allows it to be included in public pages through its flexible shortcode. However, there are custom cases where you might need to extract individual bits/figures from the stats table, raw as they are.

This is easily achieved through the high-level functions exposed by the plugin. The main player here is the function PPC_generate_stats::produce_stats. The following example snippet will extract the total adsense revenue for the given $author_ID:

PPC_general_functions::get_default_stats_time_range( PPC_general_functions::get_settings('general') );
$start_time = $ppc_global_settings['stats_tstart'];
$end_time = $ppc_global_settings['stats_tend'];
 
$author_ID = 1;
$stats = PPC_generate_stats::produce_stats($start_time, $end_time, array( $author_ID ));
$raw_stats = $stats['raw_stats'];
$total_adsense = $raw_stats[$author_ID]['total']['ppc_payment']['due_payment']['adsense_revenues'];

It will work with the default time range, but it can be changed by feeding UNIX timestamps as values of $start_time and $end_time.

Such a call of produce_stats will generate stats only for the given author, and is thus efficient. Taking away the third argument is possible, and will result in posts from any authors to be queried (and is more performant than making multiple calls with different author parameters). It is technically possible to query posts for a set of authors (in fact, notice the array-like third parameter), but there is no UI that exposes that feature in the stats page.

Adding

var_dump($raw_stats[$author_ID]['total']);

will result in exposing the data structure and show all possible choices of payment criteria and information that can be extracted.

Filed Under: Developer documentation, Tutorials

How to mark posts as paid and pay with PayPal

March 23, 2017 by Stefano 4 Comments

One of the most useful features of the PRO version is the Mark as paid one. This tutorial will guide you through how you can mark authors and posts as paid with Post Pay Counter, and how to use the plugin to pay authors through PayPal in just a few clicks.

Marking as paid is useful especially because it allows for automated payment managing! You will not need to take care of how much you paid an author last month and how much you should pay him this month. The plugin will keep a payment history and will make all the math needed.

Setting up permissions

First thing you need to care about is permissions. Post Pay Counter has detailed permissions settings to keep users from accessing features they should not. You yourself may not yet have access to payment features because you lack permissions to do so.

Head over to Post Pay Counter > Options and look for the Permissions box. Let’s start by ticking all payment-related permissions. Of course, you can play around with them and decide exactly which you want to be active, but we are going to present all the available features now.

When your setup will be complete, you may want to personalize user settings in order to hide those features from normal users and only see them yourself.

Mark as paid posts and authors

Payments happen in the stats page, so let’s go to Post Pay Counter > Stats now. Payment features are available both in the general stats view (where authors are displayed) and in the detailed stats view (where posts details from a single author are displayed). We will be showing them off for the detailed view of a specific author now.

[Read more…]

Filed Under: Tutorials Tagged With: mark as paid, paypal, post pay counter pro

Pay writers per visit on WordPress

January 16, 2015 by Stefano 27 Comments

If you are using the Post Pay Counter plugin to calculate and keep track of how much money each author should be paid for their posts, there are currently at least three sure ways to pay authors per visit.

1. Google Analytics visits

Post Pay Counter PRO allows you to automatically pull views data from your Google Analytics account and use it to compute payments. Since Analytics is possibly the most accurate and reliable visits-counting method, this should be the preferred choice. Here is the tutorial on the setup and its working, if you want to know more.

Pay writers per visit WordPress - Analytics

[Read more…]

Filed Under: Tutorials Tagged With: post pay counter, visits

Google Analytics setup and configuration with Post Pay Counter PRO

April 26, 2014 by Stefano

Post Pay Counter PRO allows you to pay your writers on WordPress basing on how many Google Analytics visits their posts logged. This tutorial shows how to set it up. After setting it up, you may be interested in putting up an effective visits payment flow.

Note: Post Pay Counter PRO does not keep track of Analytics visits, it can only use them to compute the payments. For the tracking you will need something like Google Analytics for WordPress.

First thing to look for is the Google Analytics Settings box. Every section is explained quite in detail, but what is important is that you go through these settings before going on with the setup. They are already set up in a standard and usually-fine way, but if you do want to change them, you should do that before anything else. Don’t forget to hit the Save options button when you are done.

[Read more…]

Filed Under: Tutorials Tagged With: google analytics, post pay counter pro

Share Adsense Revenues in WordPress with Post Pay Counter

May 15, 2015 by Stefano 51 Comments

More and more websites are paying users with a share of the Adsense revenues their posts generate: Post Pay Counter PRO now allows you to automatically get the total Adsense revenue for each post, calculate the share due to an author, and display all data in a nice stats table, ready for payment and record storing.

Authors don’t have to provide their Adsense code, nor they need to even have one. In fact, all revenues go into the site admin account, and Post Pay Counter will split with the authors the revenue generated only on the posts that they have written.

Revenues3

Adsense 3

Let’s get started to see how sharing Adsense revenues in WordPress works.

[Read more…]

Filed Under: Tutorials Tagged With: post pay counter pro

Display stats details in public pages with Post Pay Counter PRO shortcode

July 16, 2014 by Stefano 39 Comments

One of the most appreciated features of Post Pay Counter PRO is the shortcode, which provides the ability to display the statistics and payment details in public pages. The stats table will use your theme’s style and will be thus seamlessly integrated with the look of your site.

If you are using BuddyPress on your site, be aware that it is also possible to integrate Post Pay Counter with BuddyPress Members page with our BuddyPress addon.

This allows your users to see stats without having to access the admin section. This is useful when users are not supposed to ever access wp-admin, neither for writing posts nor for any other matter. In this way, they will not need to access wp-admin to see their earnings and to interact with the plugin.

Shortcode usage

The shortcode is [ppc]. If you use it as it is, with no parameters, the default stats page will be shown: general stats with a time range which is the default one set in Options > Misc settings > Default stats time range. This is what you would see if you just went to the wp-admin Stats page.

[Read more…]

Filed Under: Tutorials Tagged With: post pay counter pro, shortcode

PayPal setup and configuration with Post Pay Counter PRO

April 15, 2014 by Stefano

Post Pay Counter PRO does not only compute payments on your WordPress blog, but it allows you to pay your writers without having to manually head to PayPal’s website and enter the amounts and emails. Up to 6 users can be paid at a time, each transaction needs to be explicitly authorized before it is completed (works just like a Checkout page), currency conversion is supported and it is possible to choose whom pays the PayPal fees, either the admin (sender) or the users (receivers). The plugin works with the Adaptive Payments API, if you ever wanted to know.

This tutorial will walk you through setting up PayPal with the plugin. If you want to know how to actually pay authors, see this other tutorial. To know how users can enter their PayPal addresses, see this tutorial.

[Read more…]

Filed Under: Tutorials Tagged With: paypal, post pay counter pro

Set up an effective payment flow for lifetime visits

May 27, 2016 by Stefano Leave a Comment

If you already know how to pay your writers per visits, you may want to pay them for all the visits their posts record through all time, not just for the current month. This can be easily achieved through the PRO version mark as paid feature. This tutorial will guide you through how to set up the payment flow in order to achieve that.

How to pay authors per views across multiple months

  1. If you use Google Analytics, make sure you have selected the desired start day for visits. This can be done through the Update Analytics Data feature in the Google Analytics Status box. For example, if you want to pay writers for views since the beginning of 2016, then you need to select 2016/01/01. You may well want to start counting visits since the day you install the plugin, in which case just select that day or don’t do anything.
    [Read more…]

Filed Under: Developer documentation, Tutorials Tagged With: google analytics, mark as paid, post pay counter pro, visits

How to set users’ PayPal email address

September 9, 2017 by Stefano

Post Pay Counter PRO allows to pay authors through PayPal with ease. However, users must enter the PayPal email address which they would like to be paid to, for the feature to work.

There are several ways in which you can make them do that.

1. Their profile page

The user profile page is the easiest place in which they can set their PayPal email address, just as any other profile settings. The feature is enabled by default and you need to take no action. However, this requires that authors have access to wp-admin, at least for profile editing, which they may not depending on your setup.

PayPal-Setup-6

2. Any public page of your choice

The PRO version comes with several shortcodes for stats. It also ships a shortcode to display the PayPal email address form in any public page of your choice. You just need to create a new page, enter [ppc_user_paypal_email_settings] as text and publish it. Logged-in users visiting that page will see the apt field to enter and change their PayPal email address.

[Read more…]

Filed Under: Tutorials Tagged With: developer documentation, payments, paypal, post pay counter pro

Post Pay Counter caching features

November 18, 2019 by Stefano 2 Comments

Post Pay Counter supports caching and is compatible with WordPress caching plugins.
Post Pay Counter mostly implements caching for post stats, plugin settings, user settings and active payment criteria.

Since Post Pay Counter version 2.716 (May 2017), server side caching improves stats performance significantly.

On our tests, with several payment criteria active (words, visits, Facebook shares, comments), we manage to load around 10k posts in under 5 seconds on an average VPS with memcached. Un-cached stats may take up to 15 seconds to show up though, so the performance boost is clear. Post stats caching is active by default, and its status can be tweaked in the Miscellanea >  Performance section.


The standard caching caches stats details for each post, but actually rebuilds the stats table for every visit. Websites with massive amounts of data to handle may want to also cache the whole stats page for a given view. In other words, they may take a snapshot of a particular stats page that takes long to load, and then serve it quickly multiple times after.

[Read more…]

Filed Under: Developer documentation, Questions & Answers, Tutorials Tagged With: caching, performance, wp-cli

Exclude columns from stats in BuddyPress page

November 10, 2017 by Stefano Leave a Comment

The BuddyPress addon allows you to display Post Pay Counter author’s stats in the BuddyPress Member page. However, by default, all columns are displayed. This may include columns that you are not interested into, or that you may not want to show to authors.

Below is a PHP code that allows to exclude some columns from display.

/**
 * Exclude post status and post type from BuddyPress stats table
 */ 
function ppc_buddypress_exclude_stats_columns( $shortcode ) {
	$exclude_columns = ''; //comma separated list of columns to be excluded

	return substr( $shortcode, 0, strlen( $shortcode )-1 ) . ' exclude="'.$exclude_columns.'"]';
}
add_filter( 'ppc_buddypress_stats_shortcode', 'ppc_buddypress_exclude_stats_columns' );

You should change the following line with the columns IDs you would like to hide:

$exclude_columns = ''; //comma separated list of columns to be excluded

Valid columns IDs are: post_id, post_title, post_type, post_status, post_publication_date, post_words, post_visits, post_adsense_revenues, post_images, post_comments, post_bonus, post_total_payment, post_due_payment.

[Read more…]

Filed Under: Developer documentation, Tutorials Tagged With: buddypress

Add a custom column to the stats table

December 3, 2018 by Stefano 2 Comments

Sometimes you may want to add an additional custom column to the stats table. This cannot be achieved through native plugin features, but some light custom coding is enough.

This tutorial will provide developers a sketch code of how this can be done. It should be easily be adapted to your needs with some (PHP) coding skills. Be sure to review the code, because there are several optional checks just to showcase them (for example, permission checks).

In the example, we add a custom column to show the user email address.

[Read more…]

Filed Under: Developer documentation, Tutorials

How to pay per BBPress Topics and Replies

May 7, 2016 by Stefano Leave a Comment

It may be important for you to pay for BBPress Topics and Replies. This is especially useful, for example, if you have users on your site providing support through a BBPress forum, and want to reward them depending on the number and quality of their posts. Indeed, it is possible to pay for BBPress topics and replies with Post Pay Counter!

BBPress Topics and Replies counting typesIn fact, Post Pay Counter supports arbitrary post types, and all you need to do it enable BBPress ones.

Head over to Post Pay Counter > Options > Miscellanea > Allowed post types, and make sure you have the two fields Topic and Reply ticked, and those types of contents will be included in countings as well. You may of course enable just one of them.

And that’s it! Topic and Replies will be displayed in the Stats page just as with any other post or page.

Filed Under: Questions & Answers, Tutorials Tagged With: bbpress

Fix the All Website Data Analytics label issue

May 27, 2016 by Stefano Leave a Comment

When linking Google Analytics with Post Pay Counter PRO, you need to select which of your profiles relates to the site you are using. However, sometimes you don’t see your website name, but only a cryptic All Website Data. If you have multiple profiles to choose from, it’s virtually impossible to know which one you should pick.

Analytics All Website Data 1

This is not an issue of the plugin, but a misconfiguration in Analytics. In this tutorial you’ll learn to change the label so that it carries your website name.

[Read more…]

Filed Under: Tutorials Tagged With: google analytics, post pay counter pro

Add custom payment types to Post Pay Counter stats

September 28, 2015 by Stefano 6 Comments

Post Pay Counter allows by default paying for words, visits, comments and images. The PRO version allows you to pay for Adsense revenues and to give a custom bonus to each post, whereas other addons allow to further expand the things that can be paid for. But what if you want to add your own custom payment type? Well, PPC has some handy functions that allow you do that with ease.

[Read more…]

Filed Under: Developer documentation, Tutorials Tagged With: post pay counter

Backup Post Pay Counter data

January 15, 2017 by Stefano Leave a Comment

There are cases in which you may want to backup data from Post Pay Counter (and maybe Post Pay Counter PRO). If you have access to PhpMyAdmin, this can be easily achieved through a handful of custom queries that can pull out all relevant data. Selected rows can then be exported in a sql file, serving as a backup. The three queries are the following:

SELECT * FROM wp_options WHERE option_name IN ("ppc_settings", "ppc_errors", "ppcp_ga_stuff", "ppc_dismissed_notifications", "ppc_addons_list", "_ppcp_payment_history", "ppcp_ga_first_request", "ppcp_ga_last_request")

SELECT * FROM wp_postmeta WHERE meta_key IN ( "_ppcp_ga_visits", "_ppcp_adsense_revenue", "_ppcp_ga_data", "_ppcp_payment_history",  "_ppcp_exclude")

SELECT * FROM wp_usermeta WHERE meta_key IN ( "_ppcp_payment_history" ) OR meta_key LIKE "%ppcp_paypal_email"

These queries will extract ALL Post Pay Counter and Post Pay Counter PRO data (general settings, custom user settings, Analytics authorization information and visits for each post, payment history both for posts and authors, user PayPal emails, excluded posts from stats – it should really include ALL possible database data). Notice that other addons may need additional backup to be done.

You can then use the PhpMyAdmin Export feature to download the sql file for each query and store them safely. Below is an animated example of the process (for one query):

Post Pay Counter Backup

Filed Under: Developer documentation, Tutorials Tagged With: backup

Your cart

Number of items in cart: 0

  • Your cart is empty.
  • Total: €0.00
  • Checkout

What are you looking for?

Questions and answers

  • How do licenses work? Which one should I buy?
  • How can I use the payment features and pay through PayPal?
  • How do I set Google Analytics up and use it?
  • How do I set Google Adsense up and use it?
  • How do I set PayPal up and use it?
  • How do I use the shortcode to display stats in public?
  • Are there any known incompatibility issues?
  • Can I hide the stats box while editing a post?
  • Why posts I've never paid show up as paid?

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

This site uses cookies, as all sites on the planet do -- More info