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-allow-hidden-level-checkout.php
Last active November 24, 2015 16:05
Show levels and allow checkout (renewal) for hidden levels if the user already has that level.
/*
Show levels which are hidden on the level page if the user already has that level.
*/
function my_pmpro_levels_array($levels)
{
$member_level = pmpro_getMembershipLevelForUser($current_user->ID);
$check = false;
foreach($levels as $level)
{
@greathmaster
greathmaster / pmpro-register-helper-example-with-select-themes.php
Created November 14, 2015 04:49
Create select dropdown with themes for PMPro Register Helper
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
//define the fields
$fields = array();
@greathmaster
greathmaster / pmpro-custom-subscription-delay.php
Created November 14, 2015 06:31
Delay start of subscription to first of next month if current day of the month is less than the cut off day. Otherwise start on the first of next next month.
/*
Delay start of subscription to first of next month if current day of the month is less than the cut off day.
Otherwise start on the first of next next month. For example: A member signs up on November 6, and the ‘cutoff’ date is Nov 15.
Then they will be charged on Dec 1. But someone who signs up on Nov 17 will be charged on January 1.
Must have PMPro Subscription Delays (http://www.paidmembershipspro.com/add-ons/plus-add-ons/subscription-delays/)
installed and activated
*/
function my_pmprosd_modify_start_date($start_date, $order, $subscription_delay)
{
@greathmaster
greathmaster / pmpro-change-start-date.php
Created November 14, 2015 06:45
Change the start date of a membership.
function my_pmpro_member_startdate($start_date, $user_id, $level_id)
{
$date = strtotime("10 December 2015");
return $date;
}
add_filter('pmpro_member_startdate', 'my_pmpro_member_startdate', 10, 3);
@greathmaster
greathmaster / hide-toolbar-option-for-themed-profiles.css
Created November 17, 2015 18:49
Hide "Show Toolbar when viewing site" on themed profiles with Theme My Login
/*
Use Hide Admin Bar from Non-Admins(https://wordpress.org/plugins/hide-admin-bar-from-non-admins/)
to ensure users don't see the admin bar. The code below will hide "Show Toolbar when viewing site"
on themed profiles with Theme My Login.
*/
tr.tml-user-admin-bar-front-wrap {
display: none;
}
@greathmaster
greathmaster / exclude_category_from_pmpro_limit_views.php
Last active November 26, 2015 02:45
Excludes a category from being counted with PMPro Limit Post Views
function exclude_category_from_pmpro_limit_views()
{
global $post;
if(has_category("events", $post) && is_user_logged_in())
{
add_filter("pmpro_has_membership_access_filter", "__return_true");
}
}
@greathmaster
greathmaster / profile.php
Created November 20, 2015 20:37
Custom profile for PMPro Member Directory. Allows <br> tags in the bio.
<?php
/*
This shortcode will display the profile for the user ID specified in the URL and additional content based on the defined attributes.
*/
function pmpromd_profile_preheader()
{
global $post, $pmpro_pages, $current_user;
if(!empty($post->ID) && $post->ID == $pmpro_pages['profile'])
{
/*
@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:67c90f5a8906d14d6586
Last active December 10, 2015 16:34 — forked from strangerstudios/gist:3678054
Extend Expiration Dates For Renewed Memberships in Paid Memberships Pro
/*
Modified to transfer over unused days from old level into new level. For example:
Level 1 expires in 30 days and Level 2 expires in 180 days. If a members signs up
for Level 1 and 5 days in decides to up upgreade to Level 2, thier new expiry date
will be (30 - 5) + 180 days.
*/
//if checking out for the same level, add remaining days to the enddate
function my_pmpro_checkout_level($level)
{
global $pmpro_msg, $pmpro_msgt;
@greathmaster
greathmaster / pmpro-register-helper-get-response.php
Created December 14, 2015 17:03
Add Custom Fields from Register Helper to GetResponse
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
//define the fields
$fields = array();
$fields[] = new PMProRH_Field(