Skip to content

Instantly share code, notes, and snippets.

View kimcoleman's full-sized avatar

Kim Coleman kimcoleman

View GitHub Profile
@kimcoleman
kimcoleman / pmpro_do_membership_account_shortcode.php
Created August 23, 2018 16:21
Show the pmpro_account shortcode on the WooCommmerce My Account page for members who have a history of membership through Paid Memberships Pro.
<?php
/**
* Show the pmpro_account shortcode on the WooCommmerce My Account page for members
* who have a history of membership through Paid Memberships Pro.
*/
function pmpro_do_membership_account_shortcode() {
global $wpdb, $current_user;
if( is_user_logged_in() && defined( 'PMPRO_VERSION' ) ) { ?>
<style> .pmpro_actionlinks {display: none; } </style>
<?php
@kimcoleman
kimcoleman / pmpro-expire-soon-banner.php
Last active March 11, 2025 21:31 — forked from travislima/pmpro-expire-soon-banner.php
Create a banner that will display a message to soon to be expiring members
<?php
/**
* This code will display a renewal reminder notification banner at the top of your website for members whose membership
* level will expire within 7 days of the date they visit your site.
* 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.
*/
function pmpro_show_banner_renewal_message() {
global $pmpro_pages;
@kimcoleman
kimcoleman / my_pmpro_renew_or_change_payment_method.php
Created February 27, 2025 19:52
Let members switch payment methods but preserve their current subscription price and renewal date.
<?php
/**
* Get the next payment date for a user's level inclusive of subscriptions and expiration dates.
*
* If the current user has a subscription for a passed level ID, return the next payment date for that subscription.
* Otherwise, if the user has an expiration date set for the level, return that.
* Otherwise, return null.
*
* @param int $level_id The level ID to check for.
* @return int|null The next payment date/expiration date as a timestamp or null.
@kimcoleman
kimcoleman / my_pmpro_paypal_button_image.php
Last active February 10, 2025 16:35 — forked from strangerstudios/my_pmpro_paypal_button_image.php
Using the pmpro_paypal_button_image filter to change the PayPal button image on the PMPro checkout page.
<?php
/**
* Change the PayPal button image on the Paid Memberships Pro - Membership Checkout 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/
*/
function my_pmpro_paypal_button_image( $url ) {
@kimcoleman
kimcoleman / elementor_compatibility_for_pmpro.php
Last active February 4, 2025 15:48
Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder.
<?php
/**
* Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder:
* https://wordpress.org/plugins/elementor/
*
* Your administrator-level account must have a Membership Level in order to edit all of the pages assigned
* under Memberships > Pages.
*
* You must also set a Custom Field on the Membership Checkout page with the key 'pmpro_default_level' and
* value of a level ID in order to properly edit your Membership Checkout page using Elementor.
@kimcoleman
kimcoleman / custom_pmproeewe_email_frequency.php
Last active January 7, 2025 19:59
Filter the settings of email frequency when using the Extra Expiration Warning Emails Add On
<?php
/**
* Filter the settings of email frequency sent when using the Extra Expiration Warning Emails Add On
* https://www.paidmembershipspro.com/add-ons/extra-expiration-warning-emails-add-on/
*
* Update the $settings array to your list of number of days => ''.
* Read the Add On documentation for additional customization using this filter.
*/
function custom_pmproeewe_email_frequency( $settings = array() ) {
@kimcoleman
kimcoleman / my_pmpro_enqueue_theme_frontend_css.php
Last active January 2, 2025 16:34
Legacy code to enqueue a theme or child theme's version of frontend.css for PMPro v3.1+.
<?php
/**
* Enqueue your theme or child theme's version of the legacy frontend.css file.
* Note: PMPro v3.1+ css selectors have been overhauled and many of the legacy class names are no longer supported.
*/
function my_pmpro_enqueue_theme_frontend_css() {
if ( is_admin() ) {
return;
}
@kimcoleman
kimcoleman / my_pmproup_wp_parent_page_redirect.php
Last active December 23, 2024 18:20
Redirect the Top Level User Page (parent page of all user pages) to a custom page (not the homepage, which is default for non-admins in the User Pages Add On).
<?php
/**
* Redirect the main user page parent to a custom page.
*/
function my_pmproup_wp_parent_page_redirect() {
global $wpdb, $post, $current_user;
// Return early if the User Pages Add On is not active.
if ( ! function_exists( 'pmproup_getOptions' ) ) {
return;
@kimcoleman
kimcoleman / my_coa_demo_pmpro_gettext_changes.php
Created December 12, 2024 15:27
Changing frontend plugin text using gettext filter. Used for the Condo Owner's Association Demo at https://coa.pmproplugin.com/
<?php
function my_coa_demo_pmpro_gettext_changes( $translated_text, $text, $domain ) {
if ( $domain == 'pmpro-shipping' ) {
if ( $text == 'Shipping Address' ) {
$translated_text = 'Mailing Address';
}
}
return $translated_text;
}
@kimcoleman
kimcoleman / condo_units_table_shortcode.php
Created December 12, 2024 15:26
Shortcode for Units directory. Used for the Condo Owner's Association Demo at https://coa.pmproplugin.com/
<?php
/**
* Shortcode to display a table of units, owners, and residents.
*/
function condo_units_table_shortcode( $atts ) {
global $wpdb;
// Shortcode attributes with defaults
$atts = shortcode_atts( array(
'meta_key' => 'unit', // The usermeta key to retrieve unit numbers