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 / update_currency_per_level.php
Created December 7, 2017 20:43 — forked from strangerstudios/update_currency_per_level.php
Change currencies depending on Paid Memberships Pro level. Add this code to your active theme's functions.php or a custom plugin. This is just an example that will need to be tweaked for your needs.
/*
Change currencies depending on Paid Memberships Pro level.
Add this code to your active theme's functions.php or a custom plugin.
This is just an example that will need to be tweaked for your needs.
Other places to look into swapping currencies:
* Levels page.
* Invoices page.
* In emails.
* In membership levels table in admin.
@greathmaster
greathmaster / directory.php
Created November 21, 2017 19:44 — forked from strangerstudios/directory.php
PMPro Member Directory Template Code with pk user meta filtering back in.
<?php
/*
Save this file to /themes/{active theme}/paid-memberships-pro/member-directory/tempaltes/directory.php
*/
/*
This shortcode will display the members list and additional content based on the defined attributes.
*/
function pmpromd_shortcode($atts, $content=null, $code="")
{
// $atts ::= array of attributes
@greathmaster
greathmaster / mainenance_mode_on.php
Created October 14, 2017 05:00 — forked from strangerstudios/mainenance_mode_on.php
Redirect users to a maintenance.html file unless they are coming from your IP address. WordPress
/*
Lock site down to just our IP
Create a file /maintenance.html that explains that maintenance mode is on.
Update your IP address in the line below.
Add this code to your active theme's functions.php or a custom plugin.
*/
function mainenance_mode_on() {
if($_SERVER['REMOTE_ADDR'] == 'YOURIPADDRESSHERE') //find your IP and edit here
return;
@greathmaster
greathmaster / mailpoet_helpers.php
Created July 11, 2017 05:23 — forked from calogxro/mailpoet_helpers.php
MailPoet: subscribe and unsubscribe a list
<?php
function mailpoet_subscribe($list_ids = array()) {
$current_user = wp_get_current_user();
$helper_user = WYSIJA::get('user','helper');
$helper_user->addSubscriber([
'user' => [
'email' => $current_user->user_email,
'firstname' => $current_user->user_firstname,
'lastname' => $current_user->user_lastname
@greathmaster
greathmaster / my_init_email_as_username.php
Last active April 25, 2017 16:48 — forked from strangerstudios/my_init_email_as_username.php
Create a random username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template.
<?php
function my_init_email_as_username()
{
//check for level as well to make sure we're on checkout page
if(empty($_REQUEST['level']))
return;
$random_username = pmpro_getDiscountCode();
if(!empty($_REQUEST['bemail']))
@greathmaster
greathmaster / pmpro-buddypress-membership-protection.php
Created March 17, 2017 19:51 — forked from eighty20results/pmpro-buddypress-membership-protection.php
Limit access to BuddyPress components for users without a valid Paid Memberships Pro membership level
<?php
/*
Plugin Name: PMPro/BuddyPress members only access
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Limit access to BuddyPress pages/components for non-members.
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: http://www.eighty20results.com/thomas-sjolshagen
*/
@greathmaster
greathmaster / pmprobuddy_update_user_meta.php
Created February 14, 2017 05:09 — forked from strangerstudios/pmprobuddy_update_user_meta.php
Sync WordPress user meta fields (e.g. those added by PMPro Register Helper) with BuddyPress profile fields.
/*
Sync PMPro fields to BuddyPress profile fields.
*/
function pmprobuddy_update_user_meta($meta_id, $object_id, $meta_key, $meta_value)
{
//make sure buddypress is loaded
do_action('bp_init');
//array of user meta to mirror
$um = array(
@greathmaster
greathmaster / pmpro_after_checkout_send_gift_certificate_email.php
Last active November 20, 2020 16:26 — forked from strangerstudios/pmpro_after_checkout_send_gift_certificate_email.php
After PMPro checkout, if the purchase is a gift level send an email to the gift recipient. (See additional functionality in comments.)
/*
Send Gift Certificate email at checkout.
Requirements:
1. Paid Memberships Pro
2. The PMPro Gift Levels Addon
3. Register Helper Add On with a "gift_certificate_email" field added via custom code.
***MODIFIED***
Adds the email shortcode !!code_url!! so we can potentially use it in a custom email template with PMPro Email Templates plugin.
@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
@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) {