Skip to content

Instantly share code, notes, and snippets.

View greathmaster's full-sized avatar
🧐

Hersha Venkatesh greathmaster

🧐
  • San Francisco, Bay Area
View GitHub Profile
@greathmaster
greathmaster / gist:67c90f5a8906d14d6586
Last active December 10, 2015 16:34 — forked from strangerstudios/gist:3678054
Extend Expiration Dates For Renewed Memberships in Paid Memberships Pro
/*
Modified to transfer over unused days from old level into new level. For example:
Level 1 expires in 30 days and Level 2 expires in 180 days. If a members signs up
for Level 1 and 5 days in decides to up upgreade to Level 2, thier new expiry date
will be (30 - 5) + 180 days.
*/
//if checking out for the same level, add remaining days to the enddate
function my_pmpro_checkout_level($level)
{
global $pmpro_msg, $pmpro_msgt;
@greathmaster
greathmaster / my_pmpro_after_change_membership_level.php
Created January 15, 2016 16:31 — forked from strangerstudios/my_pmpro_after_change_membership_level.php
Only allow users to use the trial level once with Paid Memberships Pro.
<?php
/*
Only allow users to use the trial level once.
Add this code to your active theme's functions.php
or a custom plugin.
Be sure to change the $trial_level_id variable in multiple places.
*/
//record when users gain the trial level
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
@greathmaster
greathmaster / generate_member_number_from_defined_list.php
Last active March 18, 2016 15:42 — forked from strangerstudios/generate_member_number.php
Give a "Member Number" from a list of defined values and show it on the PMPro account page.
/*
Member Numbers from Defined List
* Member numbers are generated when users are registered or when the membership account page is accessed for the first time.
*/
//Generate member_number when a user is registered.
function generate_member_number($user_id)
{
global $member_number_array = array("1111", "2222", "3333"); //add additional codes to this array
$member_number = get_user_meta($user_id, "member_number", true);
@greathmaster
greathmaster / pmpro_cancelled_level.php
Last active March 8, 2016 18:33 — forked from strangerstudios/pmpro_cancelled_level.php
Place a PMPro member in another level and give them a new expiration date when they cancel.
/*
When users cancel (are changed to membership level 0) we give them another "cancelled" level. Can be used to downgrade someone to a free level when they cancel.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
if($level_id == 0)
{
//cancelling, give them level 1 instead
$expiry_level_id = 1;
$level = pmpro_getLevel($expiry_level_id);
@greathmaster
greathmaster / my_template_redirect_upgrade.php
Last active March 11, 2016 03:02 — forked from strangerstudios/my_template_redirect_upgrade.php
Redirect away from the level page if you don't have a required level with Paid Memberships Pro.
/*
Redirect away from the level page if you don't have membership
*/
function my_template_redirect_upgrade()
{
global $pmpro_pages, $pmpro_level;
if(empty($pmpro_pages))
return;
@greathmaster
greathmaster / pmpro-buddypress.php
Last active January 8, 2017 20:21 — forked from strangerstudios/gist:3111478
Lockdown BuddyPress with Paid Memberships Pro Example
<?php
/*
Plugin Name: PMPro BuddyPress Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-buddypress-customizations/
Description: Example code to lock down parts of BuddyPress with PMPro
Version: 0.2
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@greathmaster
greathmaster / pmpro_cancel_on_next_payments_date.php
Created March 29, 2016 17:22 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id)
{
@greathmaster
greathmaster / discounts.php
Last active October 26, 2020 18:58 — forked from eighty20results/discounts.php
Add discount code column to order list
function my_pmpro_add_cols_header($order_ids) {
ob_start(); ?>
<th>Discount Code</th><?php
return ob_get_clean();
}
add_filter('pmpro_orders_extra_cols_header', 'my_pmpro_add_cols_header');
function my_pmpro_add_cols_body($order) {
@greathmaster
greathmaster / my_bp_get_signup_page.php
Created February 7, 2017 20:12 — forked from strangerstudios/my_bp_get_signup_page.php
Filter the BuddyPress Registration page to the Membership Levels page.
<?php
/*
Filter the BuddyPress Registration page to the Membership Levels page.
*/
function my_bp_get_signup_page( $page )
{
//is PMPro activated?
if(defined('PMPRO_VERSION'))
{
//filter the BuddyPress registration page to PMPro levels page