Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / my-pmpro-change-admin-email.php
Last active Jan 18, 2021
Change the admin email for all Paid Memberships Pro admin emails.
View my-pmpro-change-admin-email.php
<?php
/**
* Change the email address for all admin related emails in Paid Memberships Pro.
* Follow this guide to add custom code to your WordPress site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_admin_to_email( $email ){
if( strpos( $email->template, "_admin" ) !== false ) {
$email->email = 'memberadmin@someemail.co';
}
@andrewlimaza
andrewlimaza / my_pmpro_ipn_check_receiver_email.php
Last active Jan 8, 2021 — forked from strangerstudios/my_pmpro_ipn_check_receiver_email.php
Allow other receiver/business email addresses for PMPro IPN Messages.
View my_pmpro_ipn_check_receiver_email.php
<?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( 'bbb@gmail.com', $email ) ) { //change email here to the old email
$check = true;
}
@andrewlimaza
andrewlimaza / pmpro-give-series-access.php
Created Jan 7, 2021
Give members immediate access to Series content [Paid Memberships Pro]
View pmpro-give-series-access.php
<?php
/**
* Give user's with a certain level access to all Series without waiting.
* Adjust the $all_access array with level ID's you want this to apply to.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_give_members_immediate_access_to_all_series_content( $drip, $member_days, $delay, $user_id ) {
$user_level = pmpro_getMembershipLevelForUser( $user_id );
@andrewlimaza
andrewlimaza / update-user-meta-on-subscription.php
Created Jan 4, 2021
Update user meta on subscription payment completed for Paid Memberships Pro.
View update-user-meta-on-subscription.php
<?php
/**
* Update user meta when a recurring payment occurs and an order is created inside Paid Memberships Pro.
* Follow this guide to add code to your WordPress site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Hook reference: https://www.paidmembershipspro.com/hook/pmpro_subscription_payment_completed/
*/
function my_change_meta_on_payment_received( $morder ) {
update_user_meta( $morder->user_id, 'meta_key', 'my value' );
}
add_action( 'pmpro_subscription_payment_completed', 'my_change_meta_on_payment_received', 10, 1 );
View my-pmpro-remove-max-failed-payments-paypal.php
<?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 / change-set-expiration-date-pmpro-renewal.php
Created Dec 21, 2020
Change Set Expiration Date value for existing members/renewals
View change-set-expiration-date-pmpro-renewal.php
<?php
/**
* Changes the Y-M-D value for existing members when using the Set Expiration Date Add On.
* Allows you to extend renewal dates for Set Expiration Dates Add On
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_set_expiration_renewal_date( $date ) {
global $pmpro_pages, $pmpro_level;
@andrewlimaza
andrewlimaza / enrol-users-into-sensei-lms-course.php
Last active Jan 12, 2021
Enrol users into a Sensei LMS course from Zapier [WP Zapier]
View enrol-users-into-sensei-lms-course.php
<?php
/**
* Enrol a learner to a Sensei LMS course when creating or updating a user from Zapier.
* Requires Sensei LMS and WP Zapier plugin.
*
* See https://yoohooplugins.com/plugins/zapier-integration/
*/
function my_wp_zapier_enroll_user_sensei_lms( $user_id ) {
// Bail if Sensei LMS isn't active.
@andrewlimaza
andrewlimaza / show-password-login-toggle.php
Created Dec 10, 2020
Add a 'Show Password' on Paid Memberships Pro login page.
View show-password-login-toggle.php
<?php
/**
* Add a checkbox to frontend login page of WordPress to toggle the password text visible/hidden.
*
* Add this code to a custom plugin or Code Snippets Add On: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Source: https://www.w3schools.com/howto/howto_js_toggle_password.asp
*/
function my_pmpro_show_password_login_toggle( $items, $args ) {
@andrewlimaza
andrewlimaza / pmpro-ap-give-shortcode-access.php
Created Nov 27, 2020
Give user's access to all content on an Addon Packages Page if purchased. Includes PMPro [membership] shortcode.
View pmpro-ap-give-shortcode-access.php
<?php
/**
* Give's users that purchase an Addon Package access to shortcodes that aren't for their level.
* User's with level 1, will gain access to all content on a purchased Addon Package item such as [membership level="2"]This content[/membership]
*
* 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/
*/
@andrewlimaza
andrewlimaza / update-users-start-date.sql
Last active Nov 27, 2020
SQL to update a specific user's start date [Paid Memberships Pro]
View update-users-start-date.sql
/**
* Please have a backup before running this script on your database
* Adjust the database prefix 'wp_' to match that of your database.
* You may alter the WHERE clause for any condition you would like.
**/
UPDATE wp_pmpro_memberships_users
SET startdate = '2020-01-01 00:00:00'
WHERE user_id = 1 AND membership_id = 3 AND status = 'active'
You can’t perform that action at this time.