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 / pmpro-sort-members-by-enddate.php
Last active May 16, 2019 19:05
Sort Members by enddate
function my_custom_memberslist_order($sqlQuery)
{
echo "<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=asc').">Sort by Enddate ASC</a><br>".
"<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=desc').">Sort by Enddate DESC</a>";
if(isset($_REQUEST['enddate_sort']) && ($_REQUEST['enddate_sort'] == 'asc' || $_REQUEST['enddate_sort'] == 'desc'))
{
$sort_order = $_REQUEST['enddate_sort'];
global $wpdb;
@greathmaster
greathmaster / pmpro-update-member-profile-notification.php
Created December 14, 2015 19:31
Show a link 'Go to Members' after updating a member profile
//Adapted from: https://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices
function my_admin_notice() {
if ( isset($_GET['updated']) ) { ?>
<div class="updated notice is-dismissible">
<?php if (!IS_PROFILE_PAGE )?>
<p><a href="<?php echo esc_url(site_url('/wp-admin/admin.php?page=pmpro-memberslist')); ?>"><?php _e('&larr; Go to Members'); ?></a></p>
</div><?php
}
@greathmaster
greathmaster / pmpro-show-address-for-offsite-gateway-only.php
Last active October 28, 2016 20:39
Only show address fields for paid levels with offsite gateways in Paid Memberships Pro...otherwise only show first and last name.
<?php
/*
Plugin Name: Paid Memberships Pro - Address For Offsite Gateways Add On - Modified
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-address-for-free-levels/
Description: Only show address fields for paid levels with offsite gateways in Paid Memberships Pro...otherwise only show first and last name.
Based on: https://github.com/strangerstudios/pmpro-add-name-to-checkout and
http://www.paidmembershipspro.com/2015/03/collect-address-for-free-levels-or-for-offsite-checkout-gateways/
Version: .3
Author: Stranger Studios
@greathmaster
greathmaster / pmpro-prorate-initial-payment.php
Created December 22, 2015 17:22
Prorate the initial payment. Useful for subscriptions that occur on the first of every month.
function my_pmpro_checkout_level($level)
{
$current_day = date('j');
$days_in_month = date('t');
$level->initial_payment = $level->initial_payment*(($days_in_month - $current_day)/$days_in_month);
return $level;
}
@greathmaster
greathmaster / pmpro-mail-chimp-grouping.php
Created January 6, 2016 16:33
Example of sending Groupings to MailChimp
<?php
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user)
{
$new_fields = array(
"groupings" => array(
array(
"name" => "Group1", //or "id" => group category id
"groups" => array("Events")
)
)
@greathmaster
greathmaster / pmpro-strip-html-tags-in-plain-text-email.php
Created January 11, 2016 19:09
Strip all HTML tags from plain text emails
function modify_plain_text_email($phpmailer)
{
$phpmailer->AltBody = wp_strip_all_tags($phpmailer->Body, false);
}
add_action("pmpro_after_phpmailer_init", "modify_plain_text_email", 10, 1);
@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 / pmpro-user-pages-show-user-subpage-links.php
Created January 27, 2016 18:08
Shows links to subpages for users. Must have Paid Memberships Pro and PMPro User Pages plugins activated.
@greathmaster
greathmaster / pmpro-redirect-confirmation-page-based-on-level.php
Created February 1, 2016 16:14
Redirect to different confirmation page based on level
<?php
function my_pmpro_confirmation_url($rurl, $user_id, $pmpro_level)
{
if(pmpro_hasMembershipLevel(1))
$rurl = "http://example.com/page_1";
elseif(pmpro_hasMembershipLevel(2))
$rurl = "http://example.com/page_2";
elseif(pmpro_hasMembershipLevel(3))
$rurl = "http://example.com/page_3";
@greathmaster
greathmaster / pmpro-discount-pricing-for-previous-members.php
Created February 18, 2016 15:44
Provide a discount for members who are expired
function custom_renewal($level)
{
global $wpdb, $current_user;
$levelshistory = $wpdb->get_results("SELECT * FROM $wpdb->pmpro_memberships_users WHERE user_id = '$current_user->ID' ORDER BY id DESC");
if($levelshistory && $levelshistory[0]->status == 'expired' && $levelshistory[0]->membership_id == $level->id)
{
$level->initial_payment = ($level->initial_payment/2);
}