Skip to content

Instantly share code, notes, and snippets.

@messica
messica / membership-card.php
Created October 4, 2019 20:20 — forked from ipokkel/membership-card.php
Sample custom membership card template to display values of Register Helper Fields on card
<?php
/**
* Custom membership-card template
* Place this directly in your theme/child-theme's root directory
* e.g.: example.com/wp-content/themes/{your active theme}/membership-card.php
*
* Use the function my_pmpro_member_card_usermeta to retrieve meta values from the usermeta table
*
*/
@messica
messica / hide_old_posts_from_members.php
Last active June 18, 2019 21:04 — forked from strangerstudios/hide_old_posts_from_members.php
Paid Memberships Pro: Hide Old Posts From New Members except specific categories.
<?php
/**
* Hide old posts from new members, except for specific categories.
*/
add_filter( 'pmpro_has_membership_access_filter', 'hide_old_posts_from_members', 10, 4 );
function hide_old_posts_from_members( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
global $wpdb;
// if PMPro says false already, return false
@messica
messica / pay-by-check-no-access.php
Last active May 31, 2019 15:53 — forked from LMNTL/pay-by-check-no-access.php
Force user's with pending orders from Pay By Check Add On and PMPro to not have access to any member content.
<?php
/**
* This checks to see if the user has a 'pending' check order and will deny access whever member content is called.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_deny_if_user_is_pending( $hasaccess, $post, $user, $levels ) {
// Only continue if post or page already requires access.
if ( empty( $levels ) ) {
return $hasaccess;
@messica
messica / generate-discount-code-pmpro.php
Last active May 23, 2019 16:08 — forked from andrewlimaza/generate-discount-code-pmpro.php
Generate a discount code for Paid Memberships Pro (with Subscription Delay)
<?php
/**
* Generate a discount code for Paid Memberships Pro. Call this function whenever you'd like to generate a new discount code.
* Adjust the code accordingly for discount uses and level settings for the discount code.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* www.paidmembershipspro.com
*/
@messica
messica / test_set_expiration_dates.php
Last active March 23, 2021 14:54 — forked from ideadude/test_set_expiration_dates.php
Testing the pmprosed_fixDate() function of PMPro Set Expiration Dates
/**
* Testing the pmprosed_fixDate function.
* 1. Make sure PMPro and PMPro Set Expiration Dates is active.
* 2. Add this code to a custom plugin.
* 3. Visit ?test_fix_date=1 to a URL
* 3a. Add &use_test_date to test from a custom date (set $now below)
* 4. Remember to remove the code when done.
*/
function test_set_expiration_dates() {
if ( empty( $_REQUEST['test_fix_date'] ) ) {
@messica
messica / pmpro_cancel_on_next_payments_date.php
Created March 30, 2017 20:58 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id) {
//are we on the cancel page?
/*
Show payment options (as levels) at checkout.
*/
// Define groups of levels. array(1,2) means that levels 1 and 2 are in a group and options will be shown for both levels at checkout for those levels.
global $pmpro_level_groups;
$pmpro_level_groups = array(array(1,2));
//show options at checkout
function pmprogl_pmpro_checkout_boxes()
<?php
/*
Plugin Name: PMPro Custom Import
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Custom Import Code for PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
<?php
/*
Plugin Name: PMPro Address For Free Levels
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-address-for-free-levels/
Description: Show address fields for free levels also with Paid Memberships Pro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
<?php
/*
Prorated payments. When a member chooses to upgrade,
he should be charged a pro-rated amount for the new membership level immediately,
and the payment date should stay the same.
Assumes initial payments are equal to billing amount.
Add this code to your active theme's functions.php or include this in a custom plugin.
*/