Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_pmproz_added_order_data_add_phone.php
Created January 2, 2022 00:41
Add phone number to the data array sent to Zapier when a new PMPro order is made.
<?php
/**
* Add phone number to the data array sent to Zapier
* when a new PMPro order is made.
*
* This gist requires the pmpro-zapier plugin.
* For information on how to add code snippets: https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
*/
function my_pmproz_added_order_data_add_phone( $data, $order, $user_id ) {
$data['phonenumber'] = get_user_meta( $user_id, 'pmpro_bphone', true );
@ideadude
ideadude / hide_fee.css
Created December 24, 2021 16:55
CSS to hide the fee on the account page in Paid Memberships Pro.
/* Remove the level fee column */
#pmpro_account-membership table.pmpro_table .pmpro_account-membership-levelfee {
display: none;
}
#pmpro_account-membership table.pmpro_table tr th:nth-child(1) {
display: none;
}
@ideadude
ideadude / my_hide_expiration_text_on_levels_page.php
Created December 19, 2021 15:54
Hide the expiration text on the levels page with PMPro.
<?php
/**
* Hide the expiration text on the levels page with PMPro.
* Add this code into a custom plugin or code snippet.
*/
function my_hide_expiration_text_on_levels_page( $text ) {
global $pmpro_pages;
if ( ! empty( $pmpro_pages['levels'] && is_page( $pmpro_pages['levels'] ) ) ) {
$text = '';
}
@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.
@ideadude
ideadude / automatically-approve-previously-approved.php
Created December 3, 2021 14:36 — forked from travislima/automatically-approve-previously-approved.php
Automatically approve, previously approved members. [Paid Memberships Pro]
<?php
/**
* Automatically approve any previously approved member.
* Requires the PMPro Approval Process for Membership Add On - https://www.paidmembershipspro.com/add-ons/approval-process-membership/
* Add this code to your site following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_automatically_approve_previously_approved( $level_id, $user_id, $cancelled_level ) {
if ( ! class_exists( 'PMPro_Approvals' ) ) {
@ideadude
ideadude / pmpro-prorate-initial-payment.php
Last active November 17, 2021 20:05 — forked from femiyb/pmpro-prorate-initial-payment.php
Prorate the initial payment. Useful for subscriptions that occur on the first of every month.
/**
* Prorate the initial payment at PMPro checkout based on the day of the month.
* You should use the Subscription Delays add on to set your subscription
* to delay until Y1-M1-01.
*/
function my_pmpro_checkout_level( $level ) {
$current_day = date( 'j' );
// Ignore if it's the first of the month.
if ( $current_day == 1 ) {
@ideadude
ideadude / pmpro_queries.sql
Last active October 24, 2022 21:22 — forked from strangerstudios/pmpro_queries.sql
Some queries around PMPro sales/etc
# successful paid orders for a given month
SELECT COUNT( * )
FROM wp_pmpro_membership_orders
WHERE
total > 0 AND
status NOT IN (
'error', 'token', 'refunded', 'pending', 'review'
)
AND TIMESTAMP > '2017-10-01'
AND TIMESTAMP < '2017-11-01';
@ideadude
ideadude / pmpro_lessons_has_archive.php
Created October 8, 2021 13:41
Update the PMPro Courses Lessons CPT to have a frontend archive page.
<?php
/**
* Update the PMPro Courses Lessons CPT to have a frontend archive page.
* Add this code into a custom plugin or Code Snippet.
* After adding this code, visit Settings -> Permalinks and save to
* 'flush the rewrite rules'.
* Then visit /lessons/ on your site.
* You can style this archive by adding a file named archive-pmpro_lesson.php
* to your child theme or theme.
*/
@ideadude
ideadude / a-gettext-filter-4-pmpro.php
Last active October 5, 2021 01:31 — forked from pbrocks/a-gettext-filter-4-pmpro.php
Sometimes we may want to change the wording of the language used in a plugin or theme, but don't want to edit code directly. A cleaner way to go is to use the built in filter that WordPress has called 'gettext'. This filter will search your codebase for translatable strings and replace when an exact match is found.
<?php
/**
* This filter will search your codebase for translatable strings and replace when an exact match is found.
*
* Here we're changing 'Membership' to 'Subscription' for Paid Memberships Pro.
*
* Add this code to your PMPro Customizations Plugin
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Note: When adding to your Customizations Plugin, be careful not to include the opening php tag on line 1 above.
*
@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.
###