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-stripe-order-description.php
Created June 30, 2018 02:47
Add the membership level ID and name to the Stripe description
//Add the membership level ID and name to the Stripe description
function my_pmpro_stripe_order_description($description, $order)
{
$membership_level = $order->getMembershipLevel();
$description = "ID: ".$membership_level->id. ", ".$membership_level->name.", ".$description;
return $description;
}
add_filter('pmpro_stripe_order_description', 'my_pmpro_stripe_order_description', 10, 2);
@greathmaster
greathmaster / pmpro-charge-different-currencies.php
Last active July 31, 2023 17:38
Set PMPro to charge in different currencies based on IP Geolocation.
/*
Set PMPro to charge in different currencies based on IP Geolocation.
Requires the GeoIP Detect plugin (https://wordpress.org/plugins/geoip-detect/)
*/
function pmpro_determine_country_from_ip()
{
global $country_from_ip;
//check if the GEO IP Detect plugin is active
<iframe src="https://amedmarket.app.box.com/embed/s/z5ywvjsia9qpllfj1yaq7gni6398ql6g?sortColumn=date" width="800" height="550" frameborder="0" allowfullscreen webkitallowfullscreen msallowfullscreen></iframe>
<iframe src="https://app.box.com/embed/s/0dtgl906gz1vsrqp1w6paqxhwuarn1mv?sortColumn=date" width="500" height="400" frameborder="0" allowfullscreen webkitallowfullscreen msallowfullscreen></iframe>
@greathmaster
greathmaster / pmpro-give-expired-members-a-level.php
Created September 21, 2017 02:35
When members expire we give them another "expired" level. If they cancel, then let them cancel.
/*
When users expire we give them another "expired" level.
When users cancel, just give them level = 0, ie same as a normal WP user.
*/
function pmpro_after_change_membership_level_default_level($level_id, $user_id)
{
//if we see this global set, then another gist is planning to give the user their level back
global $pmpro_next_payment_timestamp, $wpdb;
if(!empty($pmpro_next_payment_timestamp))
@greathmaster
greathmaster / pmpro_custom_level_cost_text.php
Created December 8, 2015 21:00
Customize the level cost text
function my_pmpro_level_cost_text($r, $level, $tags, $short)
{
//remove the existing string/level cost text
$r = '';
//initial payment
if(!$short)
$r = sprintf(__('The price for membership is <strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment));
else
$r = sprintf(__('<strong>%s</strong> now', 'pmpro'), pmpro_formatPrice($level->initial_payment));
@greathmaster
greathmaster / gist:f25c461d64e48d25735d738cddd83569
Last active March 9, 2023 16:41
Prompt for zshell to show git branch and current directory
# Set color codes for directory and Git branch
dir_color='%F{blue}'
branch_color='%F{green}'
# Set Git branch state color codes
uncommitted_color='%F{red}'
untracked_color='%F{yellow}'
ahead_color='%F{cyan}'
behind_color='%F{magenta}'
conflicted_color='%F{red}'
@greathmaster
greathmaster / pmpro-sponsored-member-message-shortcode.php
Created June 30, 2016 16:03
Creates a PMPro email shortcode for the sponsored members message to use for greater control over location of message. Use !!sponsored_message!! in email checkout body to display. Removes the automatic insertion of message at the top of the email.
/*Creates a PMPro email shortcode for the sponsored members message to use for greater control over location of message.
Use !!sponsored_message!! in email checkout body to display.
Removes the automatic insertion of message at the top of the email.
*/
function my_sponsored_email_shortcode($pmpro_email)
{
global $wpdb, $pmprosm_sponsored_account_levels;
$user_id = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . $pmpro_email->data['user_email'] . "' LIMIT 1");
@greathmaster
greathmaster / pmpro-custom-donation-categories.php
Created May 10, 2018 01:04
Donate to specific categories or causes using PMPro Register Helper.
<?php
/*Donate to specific categories or causes using PMPro Register Helper. This is different and independent from the PMPro Donations Add On.*/
function my_pmpro_checkout_level($level)
{
$donation = 0;
if(!empty($_REQUEST['donation_general_npso_gift']) && is_numeric($_REQUEST['donation_general_npso_gift']))
{
// $level->initial_payment = $level->initial_payment + ;
$donation = $donation + $_REQUEST['donation_general_npso_gift'];
@greathmaster
greathmaster / pmpro-restrict-levels.php
Created October 13, 2015 00:36
Only show levels on levels page which the original referral page belonged to.
/*
Only show levels on level page which the original content belonged to. For example if a site has 3 levels: Bronze, Silver, Gold and
a post is restricted to Silver and Gold, clicking on the "Register" button will lead them to the levels page showing only Silver and Gold levels.
To use: employ the shortcode [my_level_link] under Memberships >> Advanced >> Message for Logged-out Users (or Message for Logged-in Non-members)
Ex:
This content is for !!levels!! members only.<br /><a href="http://example.com/wp-login.php">Log In</a> <a href="[my_level_link]">Register</a>
*/