Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
<?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.
<?php
/**
* Remove or change the "Your current membership level of %s will be removed when you complete your purchase."
* text from the 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/
*/
@ipokkel
ipokkel / pmpromd-mask-phone-for-non-members.php
Created February 28, 2025 12:27
Mask a custom user field value displayed in the Member Directory for non-members .
<?php
/**
* Mask the phone number displayed in the member directory for non-members.
*
* 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_mask_phone_for_non_members( $value, $element, $pu, $displayed_levels ) {
<?php
/**
* Replace <h2> with <h5> in the no access message HTML.
*
* 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 h2_to_h5_no_access_message_html( $no_access_message_html, $level_ids ) {
@ipokkel
ipokkel / allow-post-access-for-specific-users-only.php
Last active February 24, 2025 10:40
Restrict post access to only certain members that has access to a members only post.
<?php
/**
* Allow post access for specific members (users) only.
*
* 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 allow_post_access_for_specific_users_only( $hasaccess, $post, $user, $levels ) {