Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
<?php
/**
* This recipe changes the MAXFAILEDPAYMENTS limit for PayPal
*
* 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/
*/
function mypmpro_max_failed_payments_adjust( $nvpStr, $order ){
@andrewlimaza
andrewlimaza / my_pmpro_ipn_check_receiver_email.php
Last active August 31, 2021 17:09 — forked from strangerstudios/my_pmpro_ipn_check_receiver_email.php
Allow other receiver/business email addresses for PMPro IPN Messages.
<?php
/**
* Allow other business email addresses for PMPro IPN Messages.
* To add this code to your site you may follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_ipn_check_receiver_email($check, $email) {
if ( in_array( '[email protected]', $email ) ) { //change email here to the old email
$check = true;
}
@andrewlimaza
andrewlimaza / pmpro-redirect-non-members.php
Created April 29, 2021 10:08 — forked from strangerstudios/pmpro-redirect-non-members.php
Paid Memberships Pro Redirect Non-members to Login/Homepage
<?php
/*
Redirect to login or homepage if user is logged out or not a member
Add this code to your active theme's functions.php file.
*/
function my_template_redirect()
{
global $current_user;
$okay_pages = array(pmpro_getOption('billing_page_id'), pmpro_getOption('account_page_id'), pmpro_getOption('levels_page_id'), pmpro_getOption('checkout_page_id'), pmpro_getOption('confirmation_page_id'));
@andrewlimaza
andrewlimaza / pmprosus_pmpro_email_data_edit.php
Last active May 18, 2021 10:01 — forked from femiyb/pmprosus_pmpro_email_data_edit.php
Edit Email Data for PMPro Signup Shortcode
<?php
/**
* Edit the Signup Shortcode password that is generated and emailed to the customer.
* Add this code to your site by following this guide: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
remove_filter('pmpro_email_data', 'pmprosus_pmpro_email_data', 10, 2);
function pmprosus_pmpro_email_data_edit($data, $email) {
if ( function_exists( 'pmpro_start_session' ) ) {
@andrewlimaza
andrewlimaza / pmpro-lock-membership-levels-lock-all-existing-members.php
Last active March 7, 2022 16:56 — forked from greathmaster/pmpro-lock-membership-levels-lock-all-existing-members.php
PMPro Lock Membership Levels-lock existing members. Add this to your customizations plugin and refresh the page. Recommend deleting the code snippet after the operation is complete.
<?php
/**
* Bulk Update all member's with level ID 4 to be locked indefinitely.
* Run this code by adding to your site, loading a page. Once done, you may remove this code from your site.
*/
function bulk_lock_all_members() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
@andrewlimaza
andrewlimaza / make_old_posts_free.php
Last active August 31, 2021 10:01 — forked from strangerstudios/make_old_posts_free.php
Make any post older than 18 months available for free with Paid Memberships Pro.
<?php
/**
* Allow non-members to view restricted posts if they are less than 30 days old.
* Change the '-30 Days' below if you'd like to allow access for longer or shorter.
* Adjust $categories array for the categories this should apply to.
* Add this code to your Customizations Plugin by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function open_new_posts_to_non_members($hasaccess, $thepost, $theuser, $post_membership_levels) {
global $wpdb;
@andrewlimaza
andrewlimaza / open_new_posts_to_non_members.php
Created July 15, 2021 08:43 — forked from strangerstudios/open_new_posts_to_non_members.php
PMPro Customizations to allow non-members to view restricted posts if they are less than 30 days old.
/*
Allow non-members to view restricted posts if they are less than 30 days old.
Add this code to a custom plugin.
Change the '-30 Days' below if you'd like to allow access for longer or shorter.
*/
function open_new_posts_to_non_members($hasaccess, $thepost, $theuser, $post_membership_levels)
{
global $wpdb;
@andrewlimaza
andrewlimaza / pmpro-customizations.php
Last active July 28, 2021 10:52 — forked from strangerstudios/pmpro-customizations.php
Tax solution for British Columbia, Canada to be used with Paid Memberships Pro
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@andrewlimaza
andrewlimaza / checkout_levels_api_demo.php
Created August 16, 2021 08:00 — forked from dparker1005/checkout_levels_api_demo.php
2 demos to demonstrate the PMPro checkout_levels API call.
<?php
// Copy from below here...
/*
* Add widget to checkout to get result of checkout_levels API call when button is pressed.
*/
function my_pmpro_test_checkout_levels_api() {
?>
<hr/>
@andrewlimaza
andrewlimaza / my_template_redirect_require_membership_access.php
Last active September 8, 2021 07:49 — forked from kimcoleman/my_template_redirect_require_membership_access.php
Redirects members-only content to the Membership Levels page if a user is logged out or not a member.
<?php
/*
* Redirects members-only content to the Membership Levels page if a user is logged out or not a member.
*/
function my_template_redirect_require_membership_access() {
if ( function_exists( 'pmpro_has_membership_access' ) && ( ! pmpro_has_membership_access() || pmpro_hasMembershipLevel( array( '1' ) ) ) ) {
wp_redirect( pmpro_url( 'levels' ) );
exit;
}