Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
<?php
/**
* Cancel membership level and subscription at payment gateway when a member is denied.
*
* 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_cancel_subscription_on_denial( $user_id, $level_id ) {
@ipokkel
ipokkel / redirect-old-members-to-membership-account.php
Created May 21, 2025 10:23
Redirect old members to the membership account page on login.
<?php
/**
* Redirect old members to the membership account page on login.
*
* 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_login_redirect_old_members_to_membership_account( $redirect_to, $request, $user ) {
<?php
/**
* Flush WordPress user meta cache.
*
* Add the flushmetacache parameter to the admin URL to flush the user meta cache.
* e.g., http://your-site.com/wp-admin/admin.php?flushmetacache=1
*
* 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.
<?php
/**
* Change the "Choose a membership level" wording on the Paid Memberships Pro account 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_account_page_gettext_changes( $translated, $text, $domain ) {
global $pmpro_pages;
@ipokkel
ipokkel / my-pmprogroupacct-get-group-parent-id.php
Created May 13, 2025 10:10
Helper function to retrieve the group parent User ID of the latest group account a user subscribed to.
<?php
/**
* Helper function to get the parent ID of a group account for a given user.
*
* 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_pmprogroupacct_get_group_parent_id( $user_id ) {
@ipokkel
ipokkel / add_password_to_pmpro_checkout_email.php
Last active May 7, 2025 07:50 — forked from kimwhite/add_password_to_pmpro_checkout_email.php
Add Password to checkout email for Paid Memberships Pro.
<?php
/**
* Add the user's password to the checkout emails.
*
* Please be sure to take proper precautions when dealing with user's passwords and sending out emails.
* This is for demonstrative purposes.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
**/
function add_password_to_pmpro_checkout_email( $body, $email ) {
<?php
/**
* Set default values for specific checkbox group fields.
* This function hooks into the fields before they're added to a form
*
* Set your checkbox group field names and default values in the $defaults array.
*
* 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.
<?php
/**
* Automatically add paragraphs for set elements displayed on the member directory.
*
* 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_pmpromd_display_element_html( $value, $element, $pu, $displayed_levels ) {
<?php
/**
* Require user to reside in specific countries to register for membership levels.
*
* This recipe restricts membership checkout based on the user's country of residence.
*
* === CONFIGURATION INSTRUCTIONS ===
*
* 1. ALLOWED COUNTRIES (Line 29)
* - Edit the $allowed_countries array in the my_pmpro_allowed_countries() function
<?php
/**
* Automatically add paragraphs for set elements displayed on the member directory.
*
* 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_pmpromd_wpautop_elements( $value, $element, $pu, $displayed_levels ) {