Skip to content

Instantly share code, notes, and snippets.

@eighty20results
eighty20results / pmpro_cancel_on_next_payments_date.php
Last active July 17, 2019 20:22 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date to be the end of the payment period, instead of cancelling immediately (except when payment gateway is causing cancellation)
<?php
/*
Change cancellation to set expiration date et expiration date to be the end of the current month, instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
*/
function e20r_stripe_delete_action( $user_id ) {
@ideadude
ideadude / my_pmprowoo_woocommerce_product_is_on_sale.php
Created June 15, 2018 19:24
Consider member prices a "sale" so regular price is shown with a strikethrough with WooCommerce and PMPro WooCommerce
/**
* Consider member prices a "sale" so regular price is shown with a strikethrough
* If PMPro WooCommerce is active and setup to discount prices,
* then the calls to $product->get_price() will be filtered to return
* the member price.
*
* Add this code to a custom plugin.
*/
function my_pmprowoo_woocommerce_product_is_on_sale( $on_sale, $product ) {
$regular_price = (float) $product->get_regular_price();
@andrewlimaza
andrewlimaza / auto-populate-cf7-pmpro-members.php
Created March 8, 2019 12:13
Auto-populate Contact Form 7 select field with active member names [Paid Memberships Pro]
<?php
/**
* Auto-populate user names for active members in a field drop-down.
* This will assume you are using a select field named "membership-list"
* The value of the select is the user's email and the label is set to the user's login name.
* Data Example: <option value="someemail@test.com">Test User</option>
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_auto_populate_members ( $tag, $unused ) {
@andrewlimaza
andrewlimaza / redirect-member-away-from-page.php
Created August 6, 2018 08:13
redirect user away from the page if they do not have a specific membership level.
<?php
/**
* This will redirect members with level 1 from site.com/page-slug to the home page.
* Please adjust accordingly and add to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function redirect_member_from_page_x() {
if ( is_page( 'page-slug' ) && pmpro_hasMembershipLevel( 1 ) ) {
wp_redirect( home_url() ); //redirect to home page. Change home_url() to home_url( '/page-slug' ) to redirect to specific page.
@andrewlimaza
andrewlimaza / redirect_users_to_a_new_page.php
Created July 4, 2017 14:49
Redirect users away from 'account' page in PMPro if they do not have a membership/logged-in
<?php
/**
* Redirect user's to a new URL instead of the 'levels' page in PMPro.
* Add this code to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function redirect_users_to_a_new_page( $url ){
return 'https://some-url.com'; //change this to the URL you would like to redirect your user's to.
@andrewlimaza
andrewlimaza / redirect-non-members-to-content-restricted.php
Last active June 9, 2020 13:37
Redirect non-members to 'Content Restricted' BuddyPress page for normal content.
<?php
/**
* Redirect non-members away from 'normal' content to BuddyPress content restricted page.
* Requires the BuddyPress Integration to be installed - https://www.paidmembershipspro.com/add-ons/buddypress-integration/
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_template_redirect_require_membership_access() {
if ( ! pmpro_has_membership_access() && ! bp_current_component() && ! is_archive() && ! is_home() && function_exists( 'pmpro_bp_redirect_to_access_required_page' ) ) {
pmpro_bp_redirect_to_access_required_page();
@andrewlimaza
andrewlimaza / pmpro-edit-other-emails.php
Last active August 20, 2020 12:31
Stop PMPro from editing other WordPress email formats. Remove email filter.
remove_filter( 'wp_mail_content_type', 'pmpro_wp_mail_content_type' );
@andrewlimaza
andrewlimaza / load-custom-css-level-pmpro.php
Created October 19, 2018 11:00
Load custom CSS for Membership Checkout for specific level - Paid Memberships Pro
<?php
/**
* Load custom CSS on checkoutpage for specific membership level in Paid Memberships Pro.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function load_css_for_level_checkout(){
global $pmpro_pages;
@andrewlimaza
andrewlimaza / remove_billing_example.php
Created June 12, 2017 07:48
Remove 'Billing' from 'Billing Address' title in Paid Memberships Pro.
<?php
/**
* Copy the function below into your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This function uses the gettext filter which will change all text occurences of Billing Address to Address in Paid Memberships Pro.
*/
function change_text_billing_pmpro( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing Address' :
$translated_text = __( 'Address', 'paid-memberships-pro' );
break;
@strangerstudios
strangerstudios / gist:3100680
Created July 12, 2012 20:18
Hidden Levels for Paid Memberships Pro
<?php
/*
Plugin Name: PMPro Hidden Levels
Plugin URI: http://www.paidmembershipspro.com/pmpro-hidden-levels/
Description: With this plugin, select levels are removed from the levels page but still available for checkout if you visit the checkout URL directly.
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/