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 / 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 / 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 / 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 / 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