Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@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 ) {
<?php
/**
* Change the wording of the Register link for the MemberLite theme.
*
* 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_change_memberlite_register_wording( $translated_text, $text, $domain ) {
@ipokkel
ipokkel / change-register-memberlite-theme.php
Created February 5, 2025 12:16 — forked from andrewlimaza/change-register-memberlite-theme.php
Change "Register" to "Sign Up" in Memberlite WordPress theme.
<?php
/**
* Change 'Register' wording in Memberlite theme to 'Sign Up'
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_change_memberlite_wording( $translated_text, $text, $domain ) {
switch( $translated_text ) {
case 'Register':
$translated_text = __( 'Sign Up', 'memberlite' );
break;
<?php
/**
* This recipe will hide the discount code field on the checkout page if no discount codes
* have been created for that specific level.
*
* 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/
*/
<?php
/**
* Remove punctuation from Level Cost Text for "now. starting".
*
* 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_pmprosd_level_cost_text_punctuation( $cost, $level, $tags, $short ) {
@ipokkel
ipokkel / my-pmpro-show-renew-link-when-level-expires-in-x-days.php
Created December 19, 2024 10:01
Show renewal link X days before expiration by hooking into pmpro_member_action_links. This is an alternative method to the one used in this guide: https://www.paidmembershipspro.com/schedule-renew-link-display/