Adding Split Pay to TinyPass for WordPress

No Comments

Recently we at Akilez Web Solutions were asked by a client to perform some custom modifications to a WordPress plugin from the team at TinyPass. The client had asked us to provide a method to allow them using TinyPass’ plugin to allow for a split pay option on the pay per post section. The API did indeed support split pay but it was never add to the plugin for WordPress. I can’t say whether or not the other plugins and solutions from TinyPass provide this solution, but in this case we were able to help our client.

What is Tiny Pass?

TinyPass is a paywall system. This allows webmaster’s, companies and blog owner’s to monitize their websites by providing a means to set-up a pay-for-content environment on their website. The company themselves provides plugins for major CMS systems such as WordPress, Joomla and Drupal. We will be focusing today on modifying the WordPress plugin for use with the API’s  split pay options. Split pay is a means by which as a user pays to view certain content, the website owner can share some of the revenue for that item with say, the content’s author. This is extremely useful in situations where the content wasn’t created by the website owner.

So to Add this functionality to the plugin we will need to modify four key files in the WordPress plugin. Let’s Begin!

Adding the form fields to the Pay Per Post option window

To add the form fields to the PPP option window that is configurable on every post and page in your site we will want to navigate to an edit the tinypass-form.php file located the plugin’s root.

  1. Go to Plugins->Editor
  2. Select the TinyPass plugin from the dropdown at  the top right.
  3. Find and click the tinypass-form.php In the listed files.

Next, we will insert our form fields and surrounding div tags etc. for the split pay option. Note: we are only adding code for a single split pay email and percentage. This split will be applied to any and all of the pay options you configure for that particular page/post. In a future article I will detail how you might add different split pay options for each of the three separate pay options.

On or around line 180 find the code:

[code lang='scala']<?php echo __tinypass_payment_messaging_post_display($ps) ?>[/code]

After that (line 181) insert the following:
[code lang='scala']
<div class=”postbox”>
<h3><?php _e(“Split Pay Options”) ?></h3>
<div class=”inner”>
<label for=”author_email”>Author Email</label>
<input type=”text” name=”author_email” value=”<?php echo $ps->getAuthorEmail(); ?>”/>
<br />

<label for=”split_pay”>Split Pay (%)</label>
<input type=”text” name=”split_pay” value=”<?php echo $ps->getSplitPay(); ?>”/>
<br />

The above code simply add the required input field to the TinyPass form for you to fill out . The $ps->getAuthorEmail() and  $ps->getSplitPay() methods are added in Step Three. The divs, classes and heading work with TinyPass’ included CSS to provide a consistent user interface.

Saving the form field values

Once you click “Save” the plugin attempts to save all values in this form. The plugin does this via ajax callbacks and the ajax_tp_saveEditPopup() method also located in the  tinypass-form.php file.

On or around line 46 find the code:

[code lang='scala']$ps = $ss->validatePostSettings($_POST['tinypass'], $errors);[/code]

After that (line 47) insert the following:

[code lang='scala']if (isset($_POST['author_email']) && $_POST['author_email'] != '') {

What is happening here is the author mail field value and the split pay value are being grabbed from the $_POST variable and set to the payment settings class that the plugin uses to store and process pay per post operations. Again we haven’t yet added the “get” and “set” accessors in that class yet, so let’s do that now. Be sure to save your changes to the tinypass-form.php file before moving on.

Adding “get” and “set” Accessors in the TPPaySettings Class

To add our accessors we will want to edit the /api/util/TPPPaySettings.php file. While still in the plugin editor find and open the file. You see the class and a long list of  const variables. At the end of that list add the following:

[code]const AUTHOR_EMAIL = ‘author_email’;
const SPLIT_PAY = ‘split_pay’;[/code]

These are added strictly for consistency with the plugin’s coding style. Honestly there are better methods, but moving on.

At around line 74 you should find the end of the __construct() method and this is as good a place to add our accessor(s) code. On a blank line not inside another function add:

[code lang='scala']public function getAuthorEmail() {
return $this->data->val(self::AUTHOR_EMAIL, ”);

public function setAuthorEmail($s) {
$this->data[self::AUTHOR_EMAIL] = $s;

public function getSplitPay() {
return $this->data->val(self::SPLIT_PAY, ”);

public function setSplitPay($s) {
$this->data[self::SPLIT_PAY] = $s;

Anyone familiar with modern coding practice will see that these are simple accessor functions made to get and set values for the author email and split pay amounts. Now all that remains to be done is to add the split pay to the price options.

Adding Split Pay to the Price Options

The last method in the TPPaySettings class is the create_offer() method. This method is where the magic happens and all of the setting are put to work. After the line:

[code lang=”scala’]$po = new TPPriceOption($ps->getPrice($i));[/code]

add the line:

[code lang=”scala’]$po->addSplitPay($ps->getAuthorEmail(),$ps->getSplitPay().’%’);[/code]

This line uses the API’s PriceOption class to add split pay capability to each price option in turn. Note the percent sign is added to the split pay percentage obtained from the TPPaySettings class. This is a necessary step.

That’s it, we’re done now all you have to do is to add the email address of the author that will receive the splitpay (they will need to have a TinyPass account as well) and the split percentage in the setting for any post and page you wish to give split pay on.

I hope this has helped and I want to thank our client for bringing us this new WordPress challenge.


This is author biographical info, that can be used to tell more about you, your iterests, background and experience. You can change it on Admin > Users > Your Profile > Biographical Info page."


About us and this blog

We are a full service agency that deliver compelling digital marketing solution. Our winning solutions and experience helps to deliver great results across several key areas.

Request a free quote

We offers professional SEO services that help websites increase organic search drastically and compete for 1st page rankings of highly competitive keywords.


sidebar widgets

More from our blog

See all posts
No Comments

Leave a Comment