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 / my_gettext_pay_by_check.php
Last active April 24, 2020 13:01 — forked from strangerstudios/my_gettext_pay_by_check.php
Update Pay by Check wording in pmpro-pay-by-check to something else.
<?php
/*
Change "Pay by Check" language to "Pay by Bank"
Add this code to your active theme's functions.php
or a custom plugin.
*/
function my_gettext_pay_by_check($translated_text, $text, $domain)
{
if($domain == "pmpro-pay-by-check" && $text == "Pay by Check")
@femiyb
femiyb / unset-and-hide-billing-state-field.php
Last active January 4, 2021 12:50 — forked from ipokkel/unset-and-hide-billing-state-field.php
PMPro - Remove state from required billing fields and hide it the state field.
<?php // Do NOT copy this line
/* Copy from below this line */
/*
Remove state from required billing fields and hide it the state field.
*/
// Unset state
add_action( 'pmpro_required_billing_fields', 'my_pmpro_required_billing_fields' );
@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.
/*
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 = '';
@femiyb
femiyb / pmpro-restrict-countries.php
Created May 25, 2020 14:10 — forked from strangerstudios/pmpro-restrict-countries.php
Restrict certain countries from signing up for certain levels.
function my_init()
{
global $restricted_countries;
//specify the countries not allowed to signup. The key is the level id.
$restricted_countries = array(
1 => array('FR', 'IT'),
2 => array('IT'),
);
}
@femiyb
femiyb / pmpro-mexico-gst.php
Last active May 27, 2020 09:33 — forked from strangerstudios/pmpro-australia-gst.php
Paid Memberships Pro - Australia GST
<?php
/*
Plugin Name: Paid Memberships Pro - Mexico GST
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-mexico-gst/
Description: Apply Mexico GST to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@femiyb
femiyb / pmpro_customizations.php
Last active May 27, 2020 07:20 — forked from strangerstudios/pmpro_customizations.php
Redirect users away from posts requiring membership with Paid Memberships Pro.
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-format="fluid"
data-ad-layout="in-article"
data-ad-client="ca-pub-0123456789101112"
data-ad-slot="9876543210"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<?php
/**
* Redirect non-members away from 'normal' content to BuddyPress content restricted page.
* Requires the BuddyPress Integration to be installed - https://www.paidmembershipspro.com/add-ons/buddypress-integration/
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_template_redirect_require_membership_access_buddypress() {
if ( ! pmpro_has_membership_access() && ! bp_current_component() && ! is_archive() && ! is_home() && function_exists( 'pmpro_bp_redirect_to_access_required_page' ) ) {
wp_redirect( wp_login_url() );