If you’re lucky enough to have a subscription to Premium WPMU Dev account then you’ll have access to great monetization plugins like the Upgrades or Supporter which take all the pain out of providing a ‘pay for’ service that can handle payments through Paypal, Google or even Amazon gateways.
I downloaded and installed the upgrades plugin a while ago and I’ve used it to monetize certain parts of my ComLuv site. There’s the usual way of adding plugins to the Upgrades directory and configuring them to be used which I’ll go into in a future post but I wanted to use the system slightly differently, and that was to charge users for adding new URLs to an account or to add default links to their returned list of posts.
The advantage of premium
Some of the advantages to using wpmupremium plugins is the support you receive, knowledge that the plugin will be updated to keep it compatible with new changes and my favourite is, the quality of the code.
When you’re getting premium, you’re getting premium code which for me personally, has taught me a LOT about how wordpress works. Particularly custom hooks and actions and filters. That was always a mystery to me until I dissected the plugins I downloaded from their site so it was a breeze to modify the upgrades plugin to work for users who don’t have blogs and start using the internal functions in a daughter template to do what I wanted.
Modifying the upgrades plugin

I needed to allow the upgrades menu to show for regular users because not everyone who joins the Comluv site starts a blog. This was just a simple case of changing the user level so that everyone, not just blog owners can see the menu and buy credits.
There are two places to modify:
/mu-plugins/upgrades-framework.php
line ~ 197-200 (upgrades plug pages framework function)
change add menu and submenu calls to
add_menu_page($upgrades_branding_plural, $upgrades_branding_plural, 0, 'upgrades.php');
add_submenu_page('upgrades.php', __('Credits'), __('Credits'), 0, 'credits', 'upgrades_credits_output' );
add_submenu_page('upgrades.php', __('History'), __('History'), 0, 'history', 'upgrades_log_output' );
line ~ 1919 (upgrades_credits_output function)
change user check to
if(!current_user_can('level_0')) {
Creating the daughter template
Adding another page you can use as a template is pretty easy, you just need to create a new php file in your theme directory and make sure it has the correct remarks at the top to identify it as a template page.
/*
Template Name: ComLuv purchase url
*/
Next just copy and paste the main calls from another template, you’ll be deleting most of it like the loop to display posts and replacing it with your own hard coded form and text. Be sure to keep the divs that surround the content intact.
I wrote a description of the item being sold and added a form.
(DON’T copy and paste from this page, I had to remove the beginning < characters from the code so it displays properly)
form action='/member/additional-urls/' method="POST">
input name="addurl" type="text" size="30"/>
input type="submit" name="submit1" value="Submit"/>
/form>
I also added a finish_page() function which just closes the /div tags so I could easily break out of what I was displaying without rendering the rest of the custom code below it.
You set the action to the page slug you’re publishing the page as and put a nonce field in there so you can check it with the next bit of code to prevent a naughty user from trying to call the purchase directly.
Handling the purchase
Next, you need to handle the data that gets submitted by your form and do the magic with the users credits.
if(isset($_POST['submit1'])){
$nonce=$_REQUEST['_wpnonce'];
if(!wp_verify_nonce($nonce,'addurl1')){
echo 'Page request deformed, please go back and try again. (b1s1)';
finish_page();
}
if(!$_POST['addurl']){
echo 'Please go back and enter a value';
finish_page();
}
// check if user has enough credits
global $user_ID;
$credits = upgrades_user_credits_available($user_ID);
if($credits < 3){
echo 'h2>Error - Insufficient Credits/h2>';
echo 'p>You will need to purchase some credits to register another URL, you currently have strong>'.$credits.'/strong>';
echo 'p>a href="/wp-admin/upgrades.php?page=credits">Click here to visit the purchase page/a>';
finish_page();
}
// if we're here then everything is ok to provide service and deduct credits
$credits = upgrades_user_credits_available($user_ID);
$credits -= 3;
upgrades_user_credits_update($credits);
upgrades_log_add_msg($user_ID,'You paid 3 credits for an additional URl - '.$url);
do_add_url($url,$user_ID);
echo 'h2>Site added, 3 credits used on your account/h2>';
echo 'p>You have '.$credits.' credits remaining';
echo 'p>a href="/member/additional-urls/">Click here to refresh the page/a>';
The first bit gets the nonce you created and checks it and displays an error message if it doesn’t match
Next, check the field you’re expecting and spit out an error if it is empty.
Next, check the user has enough credits and spit out an error if they don’t.
If everything is fine, continue.
use $credits = upgrades_user_credits_available($user_ID); to get the users current credits total
use upgrades_user_credits_update($credits); to set the users credits total to $credits (after you deduct what your item/upgrade costs)
use upgrades_log_add_msg($user_ID,’You paid 3 credits for an additional URl – ‘.$url); to add a message to the users Credits history page so they know they used some.
That’s it, easy peasy! Here’s an idea, use credits to sell digital downloads on another page, just check and deduct the users credits before allowing a dowload.
I’ll post a follow up to this soon on how to use the upgrades plugin to add a new package that enables the RSS widget for a blog (I’ll show you how to disable the rss widget too)
You can get over 100 plugins and themes of premium quality at http://premium.wpmudev.org and they all help to make your wpmu site better than the jones’s
165
WP-Twitip-ID Plugin – Add a twitter field to your comment form (easily)
October8
Version 1.0 (updated 11 Feb 09)
Requires: Wordpress 2.6 (could work with lesser)
Tested up to : Wordpress 2.7b3
This plugin is no longer supported, please download TwitterLink-Comments which will do a much better job and will still be able to use the existing database table and labels.
Download TwitterLink Comments
Blog News, Blog Tools, Code, PHP, Wordpress