Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@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' );
@MaryOJob
MaryOJob / mycustom_confirmation.html
Created August 30, 2021 11:30 — forked from gausam/mycustom_confirmation.html
Send additional custom confirmation email
<h3>Lorem Isupm, !!display_name!!</h3>
<p>Any content can be added here.</p>
<p>Please see the <i>Variable Reference</i> at https://www.paidmembershipspro.com/add-ons/email-templates-admin-editor/</p>
<p>Account: !!display_name!! (!!user_email!!)</p>
<p>Log in to your membership account here: !!login_link!!</p>
<?php //do not copy
/**
* This recipe update the level cost text based on the Country selected. This recipe will work
* with the VAT Tax Add On for EU customers.
*
* 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/
@JarrydLong
JarrydLong / pmpro-tax-filter-states-province.php
Last active January 4, 2022 13:55 — forked from andrewlimaza/pmpro-tax-filter-states-province.php
Custom Tax Structure For Paid Memberships Pro for States/Provinces.
<?php
/**
* This recipe will add tax based on the different Canadian regions.
*
* 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_custom_canada_tax( $tax, $values, $order ) {
<?php
/**
* This recipe will geocode the members based on their user account only.
* Run /wp-admin/?pmpromm_process_users=true to run the script.
*
* 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 / mmpu-woocommerce-enable.php
Created April 29, 2021 11:46
Allow user's to hold multiple levels with MMPU and WooCommerce for Paid Memberships Pro.
<?php
/**
* This allows user's to have multiple levels when purchasing via WooCommerce.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_filter( 'pmprowoo_mmpu_force_add_level', '__return_true' );