Skip to content

Instantly share code, notes, and snippets.

View femiyb's full-sized avatar
🏠
Working from home

Femi YB femiyb

🏠
Working from home
View GitHub Profile
@femiyb
femiyb / pmpro-south_african-vat.php
Created April 24, 2020 15:59 — forked from travislima/pmpro-south_african-vat.php
Paid Memberships Pro - South African VAT Plugin (DEVELOPING)
<?php
/*
Plugin Name: Paid Memberships Pro - South Africa VAT
Plugin URI: TBA
Description: Apply South Africa VAT to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@femiyb
femiyb / pmpro_custom_teaser_text.php
Created May 11, 2020 11:08 — forked from strangerstudios/pmpro_custom_teaser_text.php
Customize the teaser text (typically set in the advanced options) using filters with Paid Memberships Pro.
/*
Edit Teaser Messages Depending on Content
In the example below, we have 3 levels with IDs 1, 2, and 3. Level 1 is a free level.
Level 2 is a paid level. Level 3 is a higher-tiered paid level.
So each level is an upgrade over the other. All level 2 members have access to level 1 content, etc.
When showing teaser text, we check if the current post is available to free members.
If so, we show a link to register for the free level. If not, we show a link to the paid level.
@femiyb
femiyb / remove_hide_from_directory_action.php
Last active January 8, 2021 05:31
Remove 'Hide from Directory' options in the user profile page + Front End Profile
<?php
/**
* This will remove 'Hide from Directory' options in the user profile page + Front End Profile
*
* 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/
*/
@femiyb
femiyb / pmpro-include-post-limit-addon.php
Created May 13, 2020 09:35
Paid Memberships Pro Include Post Limit
<?php
function pmpro_levels_limit_page() {
if ( is_single( 'sample-page' ) ) {
add_action( 'wp', 'pmpro_lpv_wp' );
}
}
add_action( 'wp', 'pmpro_levels_limit_page', 9 );
<?php
/**
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it.
* For more information on the Register Helper Add-on please visit https://www.paidmembershipspro.com/add-ons/free-add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
**/
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
/*
PMPro percent off discount codes. Adds a text field to the discount code settings to define a percentage off the membership level. This will override any other discount code settings for the level. Currently, only works on initial one-time payments.
*/
function pmpropd_pmpro_discount_code_after_level_settings( $code_id, $level ) {
$percents = pmpro_getDCPDs( $code_id );
if ( ! empty( $percents [ $level->id ] ) ) {
$percent = $percents [ $level->id ];
} else {
$percent = '';
<?php
/**
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it.
* For more information on the Register Helper Add-on please visit https://www.paidmembershipspro.com/add-ons/free-add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
**/
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
<?php
// Add this code below to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
add_filter( 'gettext', 'change_donation_test', 20, 3 );
/**
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function change_donation_test( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
@femiyb
femiyb / my_change_text_mmpu.php
Created May 18, 2020 15:43
Change text with str_replace
<?php
/*
Replace or translate text strings that's not translatable with gettext.
*/
// Check page content and replace text strings
function my_change_text_mmpu( $text ) {
global $pmpro_pages;
<?php
/*
Disable "Admin" emails in Paid Memberships Pro
*/
add_filter('pmpro_email_recipient', 'wcpt_disable_pmpro_notifications', 10, 2);
function wcpt_disable_pmpro_notifications($recipient, $email)
{
if ($email->template == "admin_change" || $email->template == "admin_change_admin" || $email->template == "membership_expiring") {
$recipient = null;
return $recipient;