Skip to content

Instantly share code, notes, and snippets.

Avatar

Theuns Coetzee ipokkel

View GitHub Profile
@andrewlimaza
andrewlimaza / mmpu-woocommerce-enable.php
Created Apr 29, 2021
Allow user's to hold multiple levels with MMPU and WooCommerce for Paid Memberships Pro.
View mmpu-woocommerce-enable.php
<?php
/**
* This allows user's to have multiple levels when purchasing via WooCommerce.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_filter( 'pmprowoo_mmpu_force_add_level', '__return_true' );
@andrewlimaza
andrewlimaza / dynamic-read-only-field-type-rh-pmpro.php
Last active May 6, 2021
dynamic readonly example for Register Helper
View dynamic-read-only-field-type-rh-pmpro.php
<?php
/**
* Make read-only set to true for non-admins.
* This is a template, please copy code over that is needed for your own integrations.
* Follow this guide to add custom code to your membership site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
@andrewlimaza
andrewlimaza / pmpro-checkout-compatibility-wpml.php
Last active Apr 13, 2021
WPML Compatibility for Paid Memberships Pro Checkout.
View pmpro-checkout-compatibility-wpml.php
<?php
/**
* Adds support for plugins like WPML that create pages for translation.
* Improves the pmpro_is_checkout() calls to try and make it 'smarter'.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_wpml_checkout_compat( $is_checkout ) {
// If we're already on checkout, just bail.
@andrewlimaza
andrewlimaza / change-expiration-until-cancelled.php
Created Apr 12, 2021
Change Expiration Text From "---" to "Until Cancelled"
View change-expiration-until-cancelled.php
<?php
/**
* Change the account page expiration text to "Until Cancelled"
* for never expiring levels/members.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_adjust_expiration_text( $expiration_text, $level ) {
if ( $expiration_text === '---' ) {
$expiration_text = __( 'Until Cancelled', 'paid-memberships-pro' );
}
@dparker1005
dparker1005 / my_pmpro_confirmation_message_not_success.php
Last active May 10, 2021
Remove the text "Your %s membership is now active" from confirmation message if order does not have "success" status.
View my_pmpro_confirmation_message_not_success.php
<?php
// Copy from below here...
/*
* Remove the text "Your %s membership is now active" from confirmation message
* if order does not have "success" status.
*
* 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.
@ipokkel
ipokkel / make-pot.sh
Last active Apr 4, 2021
Create .pot language template file with WP-CLI. Additionally creates text-domain.po and text-domain.mo files. If previous language files exists gives the user the option to update with --merge option as well as to update all per locale language packs. #translations #localization #i18n #l10n #wordpress
View make-pot.sh
#!/bin/bash -e
# ==============================================================
# Plugin Language File Creator
# Author: Theunis Coetzee (ipokkel)
#
# This file must be placed inside the /plugin-folder/language/ folder
#
# Excecute from plugin root folder with ". languages/make-pot.sh"
# Check if executed from root, if not moves up one folder and
@ipokkel
ipokkel / stop-member-from-checking-out-for-specific-level.php
Last active Jul 11, 2021
Block specific membership level for old and current members. Hide level from levels page. Redirect level away from checkout page. Stop checkout for level.
View stop-member-from-checking-out-for-specific-level.php
<?php
/**
* This recipe will prevent members and users who has had a membership before
* from checking out for a specific level.
*
* 1. Hides level on the Membership Levels page
* 2. Redirect back to levels page if user visits checkout page.
* 3. Checks on checkout that user neither has nor had the level.
*
* This is an advanced customization recipe that may require further development
@dparker1005
dparker1005 / my_pmpro_after_change_membership_level_log.php
Created Dec 28, 2020
Creates a log at /paid-memberships-pro/logs/level-change.txt for whenever a membership level is changed.
View my_pmpro_after_change_membership_level_log.php
<?php
// Copy from below here...
/*
* Creates a log at /paid-memberships-pro/logs/level-change.txt for whenever a membership
* level is changed.
*/
function my_pmpro_after_change_membership_level_log( $level_id, $user_id, $cancel_level ) {
$logstr = "Logged On: " . date_i18n("m/d/Y H:i:s") . "\n";
@dparker1005
dparker1005 / pmprorh_required_date.php
Created Dec 17, 2020
A workaround for requiring that users fill out the RH Date field. Fails checkout if date is still the same as today's date.
View pmprorh_required_date.php
<?php
// Copy from below here...
/**
* Add a "Birthday" field via Register Helper.
*/
function my_pmprorh_init() {
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
@ipokkel
ipokkel / custom-checkout-box-location.php
Created Dec 17, 2020
Examples of how to create custom Register Helper checkout box locations, add a description to be deisplayed below the title, and set the order in which these checkout boxes are arranged, and create custom registration fields that are published in these custom checkout boxes on the membership registration form. #pmpo-register-helper #location
View custom-checkout-box-location.php
<?php
/**
* This recipe is an example of how to create custom Register Helper checkout boxes,
* add a description to be displayed below the title, and
* set the order in which these checkout boxes are arranged,
* and create custom registration fields that are published in these custom checkout boxes
* on the membership registration form.
*
* @requires Register Helper Add On
* @link https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/