Skip to content

Instantly share code, notes, and snippets.

View andrewlimaza's full-sized avatar

Andrew Lima andrewlimaza

View GitHub Profile
@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 / 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 / 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-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 / 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;
}
<?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 ){
<?php
/**
* This recipe Adds !!company!!/!!phone!! as an available variable for use in Paid Memberships Pro emails.
* When the variable is empty it will display nothing instead of the !!company!!/!!phone!! email variable
*
* Notice the array key does not include the !!s
*
* 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.
<?php
/**
* Creates shipping address fields for 'child' accounts when using the Sponsored/Group Members for Paid Memberships Pro.
* This requires the following attribute 'sponsored_accounts_at_checkout' => true for checkout.
* PLEASE NOTE: Using the Register Helper Add On (or similar) may interfere with this code if field names match.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Skill Required: Advanced.
*/
@andrewlimaza
andrewlimaza / my_pmpro_custom_tax_example.php
Last active October 22, 2020 12:36 — forked from strangerstudios/my_pmpro_custom_tax_example.php
Custom tax structure for Paid Memberships Pro where level 1 has no tax and all other levels have 7.25% tax if country is IT (Italy)
<?php
/*
Custom Tax Example.
- Requires PMPro 1.3.13 or higher.
- Leave the tax fields blank in the payment settings.
- Level 1 has no tax applied, all other levels have tax applied.
- Other levels have 22% tax for IT customers only.
- We update the price description to include the tax amount.
*/
function my_pmpro_tax( $tax, $values, $order ) {
<?php
// Copy from below here
function my_pmproarc_remove_checkbox_with_discount_code() {
?>
<script>
jQuery(document).ready(function() {
// After any AJAX call...
jQuery( document ).ajaxComplete(function() {