Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ipokkel
ipokkel / make-pot.sh
Last active April 4, 2021 11:50
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
#!/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 August 27, 2021 09:15
Block specific membership level for old and current members. Hide level from levels page. Redirect level away from checkout page. Stop checkout for level.
<?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
@andrewlimaza
andrewlimaza / my-pmpro-change-admin-email.php
Last active February 28, 2024 11:31
Change the admin email for all Paid Memberships Pro admin emails.
<?php
/**
* Change the email address for all admin related emails in Paid Memberships Pro.
* Follow this guide to add custom code to your WordPress site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_admin_to_email( $user_email, $email ){
if( strpos( $email->template, "_admin" ) !== false ) {
$user_email = '[email protected]';
}
@dparker1005
dparker1005 / my_pmpro_after_change_membership_level_log.php
Created December 28, 2020 18:21
Creates a log at /paid-memberships-pro/logs/level-change.txt for whenever a membership level is changed.
<?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 December 17, 2020 18:44
A workaround for requiring that users fill out the RH Date field. Fails checkout if date is still the same as today's date.
<?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 December 17, 2020 09:36
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
<?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/
<?php // do not copy
/**
* This recipe will add a Description field to each discount code. This is then visible on the
* Discount Codes page for admin reference.
*
* 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
/**
* This recipe will allow you to control content with all membership levels.
*
* 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/
*/
@andrewlimaza
andrewlimaza / show-password-login-toggle.php
Created December 10, 2020 09:21
Add a 'Show Password' on Paid Memberships Pro login page.
<?php
/**
* Add a checkbox to frontend login page of WordPress to toggle the password text visible/hidden.
*
* Add this code to a custom plugin or Code Snippets Add On: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Source: https://www.w3schools.com/howto/howto_js_toggle_password.asp
*/
function my_pmpro_show_password_login_toggle( $items, $args ) {
<?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/
*/