Skip to content

Instantly share code, notes, and snippets.

View dparker1005's full-sized avatar

David Parker dparker1005

  • Stranger Studios
View GitHub Profile
@dparker1005
dparker1005 / pmpro_cancel_on_next_payments_date.php
Last active November 26, 2019 18:28 — 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. In the process of updating to support MMPU.
/*
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?
@dparker1005
dparker1005 / one_time_trial_level.php
Last active April 21, 2020 13:35 — forked from strangerstudios/my_pmpro_after_change_membership_level.php
Only allow users to check out for a level one time.
<?php
/*
Only allow users to use the trial level once.
Add this code to your active theme's functions.php
or a custom plugin.
Be sure to change the $trial_level_id variable in multiple places.
*/
//record when users gain the trial level
function my_pmpro_one_time_trial_level($level_id, $user_id)
{
@dparker1005
dparker1005 / require_discount_code.php
Last active June 9, 2020 18:16 — forked from femiyb/require_discount_code.php
Require discount code on checkout
<?php
// Copy from below here
/*
* Require that a user use a discount code when reigstering for specific levels.
*/
function my_pmpro_registration_checks_require_code_to_register( $pmpro_continue_registration ) {
$restricted_levels = array( 1, 3 ); // Levels 1 and 3 require a discount code to register
global $discount_code, $pmpro_level;
@dparker1005
dparker1005 / my_pmpro_fix_wpelogin.php
Last active July 29, 2020 17:08 — forked from ideadude/my_fix_wpelogin.php
Fix password reset behavior when using PMPro login page on WP Engine hosting.
<?php
// Copy from below here...
/*
* In addition to adding this code to your site, note that
* WP Engine also has aggressive caching that your login page
* should be excluded from, especially if you experience issues
* with your login page.
* https://wpengine.com/support/cache/#Cache_Exclusions
@dparker1005
dparker1005 / remove-vp-pricing-discounut-code.php
Last active September 23, 2020 15:28 — forked from andrewlimaza/remove-vp-pricing-discounut-code.php
Remove variable pricing check and hide errors when discount code is applied.
<?php
// Copy from below here...
/**
* Remove variable pricing check and hide errors when discount code is applied.
* Follow this guide to add this code snippet to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit www.paidmembershipspro.com for more information.
*/
@dparker1005
dparker1005 / custom_addon_package_prices.php
Last active January 12, 2021 15:57 — forked from strangerstudios/custom_addon_package_prices.php
Charge different prices for different membership levels with PMPro and PMPro Addon Packages.
<?php
// Copy from below here...
/*
* Charge different prices for different membership levels.
*/
//global var to store the price configurations
global $custom_addon_package_prices;
$custom_addon_package_prices = array(
@dparker1005
dparker1005 / pmpro-sponsored-member-message-shortcode.php
Last active March 30, 2021 20:06 — forked from greathmaster/pmpro-sponsored-member-message-shortcode.php
Creates a PMPro email shortcode for the sponsored members message to use for greater control over location of message. Use !!sponsored_message!! in email checkout body to display. Removes the automatic insertion of message at the top of the email.
<?php
/*
* Creates a PMPro email shortcode for the sponsored members message to use for greater control over location of message.
* Use !!sponsored_message!! in email checkout body to display.
* Removes the automatic insertion of message at the top of the email.
*/
function my_sponsored_email_shortcode($pmpro_email)
{
global $wpdb, $pmprosm_sponsored_account_levels;
@dparker1005
dparker1005 / my_template_redirect_network_require_membership_access.php
Created November 10, 2022 16:07 — forked from kimcoleman/my_template_redirect_network_require_membership_access.php
Redirects members-only content to the Membership Levels page on the Main Network Site if a user is logged out or not a member.
<?php
/*
* Redirects members-only content to the Membership Levels page on the Main Network Site
* if a user is logged out or not a member.
*/
function my_template_redirect_network_require_membership_access() {
if ( function_exists( 'pmpro_has_membership_access' ) && ! pmpro_has_membership_access() ) {
wp_redirect( network_site_url( 'levels' ) );
exit;
@dparker1005
dparker1005 / next_last_payment_dates_members_list.php
Last active August 10, 2023 15:38 — forked from kimcoleman/next_last_payment_dates_members_list.php
Adds last payment date and next payment date to the members list and export CSV in Paid Memberships Pro (PMPro).
<?php
/**
* Adds last payment date and next payment date to the members list and export CSV.
* Note that "last payment" value will get the last order in "success", "cancelled", or "" status. (Oddly enough, cancelled here means that the membership was cancelled, not the order.)
*
* The "next payment" value is an estimate based on the billing cycle of the subscription and the last order date. It may be off from the actual recurring date set at the gateway, especially if the subscription was updated at the gateway.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
@dparker1005
dparker1005 / disable-reporting-pmpro.php
Last active January 26, 2024 20:17 — forked from andrewlimaza/disable-reporting-pmpro.php
Disable Reporting For Paid Memberships Pro
<?php
/**
* Remove tracking for Paid Memberships Pro on high traffic sites.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_disable_reporting() {