Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / pmpro-canada-tax-checkout.php
Created Jul 22, 2021
Add Canadian Tax to PMPro checkout
View pmpro-canada-tax-checkout.php
<?php
/**
* Add 13% tax to all Canadian customers checking out for a membership level.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function customtax_pmpro_tax_ca($tax, $values, $order) {
if ( $_SESSION['bcountry'] == 'CA' || $_REQUEST['bcountry'] == 'CA' ) {
$tax = round( (float) $values[price] * 0.13, 2 );
}
return $tax;
@andrewlimaza
andrewlimaza / pmpro-avada-global-footer.php
Created Jul 15, 2021
Remove Paid Memberships Pro content filtering for Avada Global Footer
View pmpro-avada-global-footer.php
@andrewlimaza
andrewlimaza / open_new_posts_to_non_members.php
Created Jul 15, 2021 — forked from strangerstudios/open_new_posts_to_non_members.php
PMPro Customizations to allow non-members to view restricted posts if they are less than 30 days old.
View open_new_posts_to_non_members.php
/*
Allow non-members to view restricted posts if they are less than 30 days old.
Add this code to a custom plugin.
Change the '-30 Days' below if you'd like to allow access for longer or shorter.
*/
function open_new_posts_to_non_members($hasaccess, $thepost, $theuser, $post_membership_levels)
{
global $wpdb;
@andrewlimaza
andrewlimaza / make_old_posts_free.php
Last active Jul 15, 2021 — forked from strangerstudios/make_old_posts_free.php
Make any post older than 18 months available for free with Paid Memberships Pro.
View make_old_posts_free.php
<?php
/**
* Allow non-members to view restricted posts if they are less than 30 days old.
* Change the '-30 Days' below if you'd like to allow access for longer or shorter.
* Adjust $categories array for the categories this should apply to.
* Add this code to your Customizations Plugin by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function open_new_posts_to_non_members($hasaccess, $thepost, $theuser, $post_membership_levels) {
global $wpdb;
@andrewlimaza
andrewlimaza / my-custom-wp-zapier-webhook.php
Created Jul 13, 2021
Custom WP Zapier webhook example
View my-custom-wp-zapier-webhook.php
<?php
/**
* Looks for a custom variable passed to WP Zapier. Adjust custom-var in your Zapier data (key/data pair)
* Add this code to your site by following this guide - https://yoohooplugins.com/customize-wordpress/
*/
function my_own_webhook_2() {
$custom_identifier = $_REQUEST['custom-var'];
// If this custom identifier isn't present, bail.
if ( ! $custom_identifier ) {
@andrewlimaza
andrewlimaza / pmpro-pdf-stop-pdfs-free.php
Created Jul 12, 2021
Stop Paid Memberships Pro PDF invoices from attaching/generating for free levels.
View pmpro-pdf-stop-pdfs-free.php
<?php
/**
* The code below stops PDF's from being generated for free Paid Memberships Pro levels/orders.
* Follow this guide to add code to your site - https://yoohooplugins.com/customize-wordpress/
*/
// Stop generating when orders are added/updated
function my_pmpro_pdf_disable_pdf_free( $generate, $order ) {
if ( ! $generate ) {
@andrewlimaza
andrewlimaza / pmpro-lock-membership-levels-lock-all-existing-members.php PMPro Lock Membership Levels-lock existing members. Add this to your customizations plugin and refresh the page. Recommend deleting the code snippet after the operation is complete.
View pmpro-lock-membership-levels-lock-all-existing-members.php
<?php
/**
* Bulk Update all member's with level ID 4 to be locked indefinitely.
* Run this code by adding to your site, loading a page. Once done, you may remove this code from your site.
*/
function bulk_lock_all_members() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
@andrewlimaza
andrewlimaza / fix-issue-payfast-day-before-sub-delay.php
Created Jun 29, 2021
Adjust Subscription Delay by one month if it's the day before [PayFast Fix]
View fix-issue-payfast-day-before-sub-delay.php
<?php
/**
* This adjusts the subscription delay (and cost text) by one month if subscription is set to start the following day.
* Fixes an issue specifically with PayFast not supporting subscriptions being created for the following day.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
* Adjust Subscription Delay Start Date if set to tomorrow.
@andrewlimaza
andrewlimaza / change-woo-shop-title.php
Created Jun 28, 2021
Change WooCommerce Shop Title
View change-woo-shop-title.php
<?php
/**
* Change the WooCommerce "Shop" page title to "Shop By Brand".
* Add this code to your site by following this guide - https://yoohooplugins.com/customize-wordpress/
*/
function my_woo_shop_page_title( $page_title ) {
if ( 'Shop' == $page_title && is_shop() ) {
$page_title = "Shop By Brand";
}
@andrewlimaza
andrewlimaza / hide-billing-details-pmpro-pdf.php
Created Jun 25, 2021
Hide "Billing Details" From Paid Memberships Pro PDF Invoice.
View hide-billing-details-pmpro-pdf.php
<?php
/**
* Hide 'Billing Details' from Paid Memberships Pro PDF Invoices.
* Add this code to your site by following - https://yoohooplugins.com/customize-wordpress/
*/
function pmpropdf_change_my_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Billing Details' :