Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
<?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 ) {
<?php
/**
* Hides empty elements on the directory and profile pages.
*
* Can be useful if you have a select type user field
* and you don't want to display them if they are empty.
* This requires the first select field option to be configured
* with no value set, a colon, and a label set. e.g. ":label".
*
* For example:
<?php
/**
* This recipe will change the "Username or Email Address" text string
* on the login page and login widget.
*
* 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/
*/
@ipokkel
ipokkel / pmpro-memberslist-add-all-membership-levels-column.php
Created April 9, 2025 08:26
Add an "All Memberships Levels" column to the members list and include it in the CSV export.
<?php
/**
* Adds "All Membership Levels" column to the Members List and export CSV.
*
* 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/
*/
// Adds "All Membership Levels" column to the Members List.
@ipokkel
ipokkel / pmpro-price-before-submit.php
Created April 8, 2025 05:46
Show the checkout price above the submit button on the PMPro Checkout page.
<?php
/**
* Display the price of the level before the submit button.
*
* 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_price_before_submit() {
@ipokkel
ipokkel / move-user-field-to-account-information-js.php
Created April 2, 2025 10:09
Example jQuery JavaScript to move a custom user field to after the email field(s) on the checkout page.
<?php
/**
* Moves a custom user field after the email fields using JavaScript.
*
* 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_move_user_field_to_account_information() {
@ipokkel
ipokkel / my-pmpro-restrict-checkout-email-domain.php
Created April 2, 2025 06:25
Restrict email domains for Membership Checkout. Optionally set specific level IDs in the $restricted_levels array to only restrict email domains for specified membership levels.
<?php
/**
* Restrict Membership Signup by Email Domain.
* To restrict all levels, leave the $restricted_levels array empty.
* To restrict specific levels only, add the level IDs to the $restricted_levels array.
* Make sure to edit the $valid_domains array defined in the my_check_for_valid_domain function
* to include only the domains you'd like to allow.
*
* 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.