Skip to content

Instantly share code, notes, and snippets.

@messica
messica / my_pmprolpv_has_membership_access.php
Created April 25, 2019 16:46
Limit Post Views: Don't allow post views for certain categories.
<?php
/**
* Limit Post Views: Don't allow post views for certain categories.
*/
function my_pmprolpv_has_membership_access( $has_access, $post ) {
// Set blocked categories here.
$blocked_categories = array( 'silver', 'gold' );
@messica
messica / my_pmpromrss_feeds.php
Last active May 16, 2023 06:05
pmpromrss_feeds filter example
<?php
/*
* PMPro RSS Extra Feeds Example
*
* Extra feeds format:
* $feeds["Label"] = Feed URL
*
* learn more about feed URLs at http://codex.wordpress.org/WordPress_Feeds
*/
@messica
messica / my_pmprosm_pmpro_registration_checks.php
Created February 6, 2019 18:32
Prevent sponsor members from checking out with their own sponsor code.
<?php
/**
* Prevent sponsor members from checking out with their own sponsor code.
*/
function my_pmprosm_pmpro_registration_checks( $continue ) {
global $current_user, $discount_code, $wpdb;
// Is a discount code being used?
@messica
messica / my_pmpro_applydiscountcode_return_js.php
Last active March 25, 2022 16:00
Display original price and discount when a discount code is applied.
<?php
/**
* Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order.
* Add this code recipe to a PMPro Customization Plugin - Display messages of the Original Price, Discounted Price and Amount Saved when discount code is applied to PMPro order
* Various classes added to strings to allow for styling - ".pmpro-discorig-message", ".pmpro-orginal-price", ".pmpro-discount-price", ".pmpro-save-price"
*
* [my_pmpro_applydiscountcode_return_js] Display original price and discount when a discount code is applied.
* @param string $discount_code [description]
* @param integer $discount_code_id [description]
@messica
messica / my_pmpro_custom_advanced_options.php
Created April 10, 2014 19:46
Add new custom fields to Advanced Settings with an array of options. Supports 'text','select', and 'textarea' as field_types.
<?php
//Add new custom fields to Advanced Settings with an array of options. Supports 'text','select', and 'textarea' as field_types.
//
//Example:
//
function my_advanced_settings() {
$custom_fields = array(
'field1' => array(
'field_name' => 'test1',
@messica
messica / my_pmpropbc_enqueue_scripts.php
Created November 30, 2018 00:56
Hide Auto-Renewal Checkbox for Check payment
<?php
/**
* Hide Auto-Renewal Checkbox for Check payment
*/
function my_pmpropbc_enqueue_scripts() {
global $pmpro_pages;
if(is_page($pmpro_pages['checkout'])) {
@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 / my_pmpro_confirmation_url.php
Created August 27, 2015 20:18
Redirect to last post viewed instead of confirmation page
<?php
/*
* Remember last post ID
*/
function my_wp() {
global $post, $pmpro_pages;
//don't track pmpro pages
if( ! in_array($post->ID, $pmpro_pages))
setcookie('last_post_viewed', $post->ID, null, '/');
@messica
messica / pmpro_customizations_gift_levels_example.php
Last active December 2, 2020 15:55
PMPro Gift Levels Example
<?php
/* PMPro Gift Levels Example */
global $pmprogl_gift_levels;
$pmprogl_gift_levels = array(
// Set level 1 as a "Purchase Gift" membership level to create a gift code for a free level 2 gift.
1 => array( // "Purchase Gift" level ID
'level_id' => 2, // Membership Level ID of the gift membership level.
@messica
messica / my_pmpro_checkout_level.php
Created July 9, 2019 18:47
Simple Proration for Upgrades Example
<?php
/**
* Simple Proration for Upgrades Example
*/
function my_pmpro_checkout_level( $checkout_level ) {
// Get user's current level.
$user_level = pmpro_getMembershipLevelForUser();