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
<?php
function my_pmpro_email_headers_admin_emails($headers, $email)
{
$args = array('role' => 'pmpro_membership_manager');
$membership_managers = get_users($args);
$membership_managers_emails = array();
foreach($membership_managers as $membership_manager)
{
$membership_managers_emails[] = $membership_manager->user_email;
@femiyb
femiyb / my_pmpro_email_headers_bcc.php
Created July 17, 2020 15:34 — forked from strangerstudios/my_pmpro_email_headers_bcc.php
BCC a second email address on PMPro admin emails.
/*
Add bcc for PMPro admin emails.
Change [email protected],[email protected] below to the addresses you want to use.
Add this code to your active theme's functions.php or a custom plugin
a la http://www.paidmembershipspro.com/2012/08/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_headers_bcc($headers, $email)
{
//bcc emails going to admins
if(strpos($email->template, "admin") !== false)
<?php
//copy lines 5 - 12 into your theme's functions.php or custom plugin
function filter_pmpro_default_country( $default_country ) {
// Set country code to "JP" for Japan.
$default_country = "JP";
return $default_country;
}
@femiyb
femiyb / my_pmpro_always_show_renew_levels.php
Created July 30, 2020 21:11 — forked from LMNTL/my_pmpro_always_show_renew_levels.php
Always show renew links for certain PMPro levels if the member already has that level.
// always show renew links for certain levels if the member already has that level.
function my_pmpro_always_show_renew_levels( $show, $level ){
/*--- change this line to the levels you want to show a renew link---*/
$show_levels = array( 1, 2 );
if( in_array( $level->id, $show_levels ) ) {
$show = true;
}
<?php
/**
* Set a default membership level when a user expires (only).
* This does not set the default level when a user cancels.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_set_default_level_only_when_expiring( $user_id, $level_id ) {
pmpro_changeMembershipLevel( 1, $user_id ); // Change this to default level.
@femiyb
femiyb / change-add-paypal-express.php
Created August 4, 2020 09:52 — forked from ipokkel/change-add-paypal-express.php
Change text for add paypal express to checkout translation strings
<?php
// Add this code below to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
add_filter( 'gettext', 'change_text_for_add_paypal_express', 20, 3 );
/**
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function change_text_for_add_paypal_express( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Choose Your Payment Method':
$translated_text = __( 'Choose Your Payment Method', 'pmpro' );
@femiyb
femiyb / pmpro_allow_access_for_admins.php
Created August 13, 2020 13:58 — forked from andrewlimaza/pmpro_allow_access_for_admins.php
Allow admins access to all restricted posts in WordPress with Paid Memberships Pro
<?php
/**
* This code snippet allows admins without any PMPro membership level to access any restricted content.
* Add this code to your PMPro Customizations plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmmpro_allow_access_for_admins($hasaccess, $mypost, $myuser, $post_membership_levels){
//If user is an admin allow access.
if( current_user_can( 'manage_options' ) ){
@femiyb
femiyb / simple_checkout_email_only_signup.php
Created August 19, 2020 14:55 — forked from kimcoleman/simple_checkout_email_only_signup.php
Only require Email Address to create user.
<?php
/**
* Only require Email Address to create user.
* This recipe requires Paid Memberships Pro and the Register Helper Add On.
*
* Note: this recipe depends on a future patch to Paid Memberships Pro core plugin in order to function.
*/
/**
* Hide the Account Information Section
<?php
/*
* Plugin Name: Paid Memberships Pro - Canadian Tax
* Description: Apply Canadian taxes to Checkouts with PMPro
* Version: .1
* Author: Stranger Studios
* Author URI: http://www.strangerstudios.com
*/
/*
@femiyb
femiyb / restrict_all_posts_for_cpt.php
Last active August 27, 2020 08:15 — forked from dparker1005/restrict_all_posts_for_cpt.php
Restricts all posts. Only users with a level can view regardless of what is set in the "Require Membership" box.
<?php
// Copy from below here...
/*
* Restricts all posts. Only users with a level can view
* regardless of what is set in the "Require Membership" box.
*
* Can change 'post' on line 12 to any CPT.
*/