Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ideadude
ideadude / my_add_extra_expiration_warning_templates.php
Last active March 26, 2024 06:44
Send extra expiration warning emails with individual templates when using PMPro and the Extra Expiration Warning Emails add on.
<?php
/**
* Send extra expiration warning emails with individual templates.
* Make sure the Extra Expiration Warning Emails Add On is also active.
* https://www.paidmembershipspro.com/add-ons/extra-expiration-warning-emails-add-on/
*
* Then add this code into a custom plugin or code snippet.
* https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
*/
// Tell the expiration warnings add on to use our templates.
@andrewlimaza
andrewlimaza / reset-user-to-pending-whenever-imported.php
Created November 10, 2021 12:00
Reset user to pending when importing from CSV.
<?php
/**
* Set the user to "pending" whenever you run an import using the Import Users From CSV Integration for Paid Memberships Pro.
*
* 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/
*/
@andrewlimaza
andrewlimaza / keep-pmpro-member-price-manual-renewal.php
Created November 4, 2021 10:33
Keep pre-existing members on their initial checkout price when renewing their membership level.
<?php
/**
* Keep pre-existing members on their initial checkout price when manually renewing. Grandfather 'old' members when their levels pricing changes.
* Note: This is not needed for recurring membership levels and is designed for levels with an expiration date.
*
* 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/
*/
@andrewlimaza
andrewlimaza / automatically-apply-discount-code-pmpro.php
Last active October 18, 2023 13:24
Automatically apply discount code to checkout for Paid Memberships Pro.
<?php
/**
* Automatically apply a discount code to Paid Memberships Pro checkout.
* Adjust the discount code that should apply to all checkouts.
* If another discount code is set, use that as prefernce.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_apply_discount_code() {
@ideadude
ideadude / my_pmpro_getfile.php
Created September 15, 2021 15:49
Lock down non-WordPress files in *multiple private directories* with Paid Memberships Pro.
<?php
/*
This code handles loading a file from one or more protected directories.
This is a variation of the code presented here:
https://www.paidmembershipspro.com/locking-non-wordpress-files-folders-paid-memberships-pro/
(!) Be sure to change the $protected_directories arary below.
(!) Add this code to a code snippet or custom plugin.
(!) You should have a corresponding bit of code in your Apache .htaccess file
to redirect files to this script. You need one line per protected dir.
###
@sc0ttkclark
sc0ttkclark / my-pmpro-redirect-to-referring-page-after-checkout.md
Last active June 6, 2022 12:44 — forked from ipokkel/my-pmpro-redirect-to-referring-page-after-checkout.php
Redirect new members and existing members that changes their existing level back to the referring page after checkout.

Some users reported the recipe not redirecting to the referer after checkout.

Updated the my_pmpro_redirect_to_referring_page_after_checkout_track function that sets the cookie here: ipokkel/32d6ba9425d4550a5861709498e00135

@MaryOJob
MaryOJob / my_pmpro_disable_reminder_email_per_level.php
Last active January 21, 2022 09:57
Disable Recurring Payment Reminder Emails for Specific Level(s) - PMPro
<?php // do not copy this line
/**
* This recipe will disable the recurring payment email reminders for the specifc levels stated
*
* 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/
*/
@andrewlimaza
andrewlimaza / pmpro-hide-activity-btn-buddypress-buddyboss.php
Last active September 6, 2021 12:12
Hide BuddyBoss activity buttons for certain membership levels.
<?php
/**
* Hide the BuddyPress/BuddyBoss activity buttons for members that don't have level 1.
* Adjust the code according to your needs.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_hide_bp_activity_meta( $buttons, $activity_id ) {
// Check if PMPro is active or not.
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) {
return $buttons;
@andrewlimaza
andrewlimaza / load-html-email-templates-from-theme.php
Last active September 9, 2021 07:44
Overwrite email templates inside Paid Memberships Pro by adding HTML templates to theme directory.
<?php
/**
* Overwrite email templates from child theme HTML templates.
* Create html templates in your child theme under paid-memberships-pro/email/
* Add this code to your site by following this guide -
*/
function cg_pmpro_load_from_theme_template( $body, $email ) {
if ( file_exists( get_stylesheet_directory() . '/paid-memberships-pro/email/' . $email->template . '.html' ) ) {
$body = file_get_contents( get_stylesheet_directory() . '/paid-memberships-pro/email/' . $email->template . '.html' );
<?php // do not copy
/**
* This recipe will display a list of pages/posts that are protected by adding the shortcode `[mypmpro_display_posts]` to a page.
*
* 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/
*/