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-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 / 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 / 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 / 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 / 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 / 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 / gist:b49b8fad921b95a462bcc4267beb5366
Created January 4, 2018 22:39 — forked from andrewlimaza/pmpro-edit-other-emails.php
Stop PMPro from editing other WordPress email formats
remove_filter( 'wp_mail_content_type', 'pmpro_wp_mail_content_type' );
@greathmaster
greathmaster / elementor_compatibility_for_pmpro.php
Created March 27, 2018 16:02 — forked from kimcoleman/elementor_compatibility_for_pmpro.php
Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder.
<?php
/**
* Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder:
* https://wordpress.org/plugins/elementor/
*
* You must also set a Custom Field on the Membership Checkout page with the key
* 'pmpro_default_level' and value of a level ID in order to properly design your
* Membership Checkout page using Elementor.
*/
function elementor_compatibility_for_pmpro() {
@greathmaster
greathmaster / pmpro_ld2aff.php
Last active March 27, 2018 22:10 — forked from strangerstudios/pmpro_ld2aff.php
Link Paid Memberships Pro discount codes to affiliate accounts from another plugin/service.
/*
Link discount codes to affiliates.
*/
//this is the parameter we're looking for to find affiliates... based on which plugin/etc you are using
//define('PMPRO_LDC2AFF_KEY', 'wpam_id'); //Affiliates Manager Plugin
define('PMPRO_LDC2AFF_KEY', 'pa'); //WordPress Lightweight Affiliates
//define('PMPRO_LDC2AFF_KEY', 'ref'); //AffiliateWP
//helper function to get the values from options and make sure they are an array
function pmpro_ld2aff_getOptions() {
@greathmaster
greathmaster / my_change_pmpro_sessions_start_and_stop.php
Created October 15, 2018 13:00 — forked from ideadude/my_change_pmpro_sessions_start_and_stop.php
Change when Paid Memberships Pro starts and stops PHP sessions.
<?php
/**
* Change when Paid Memberships Pro starts and stops PHP sessions.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_change_pmpro_sessions_start_and_stop() {
// make sure PMPro has loaded
if( !function_exists( 'pmpro_start_session' ) ) {
return;
}