Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@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 ) {
<?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() {