This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* track a custom page and its level in pmpro-google-analytics | |
* | |
* title:track a custom page and its level. | |
* layout: snippet | |
* collection: add-ons, pmpro-google-analytics | |
* category: analytics, custom page, custom checkout page | |
* link: TBD | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#give all non-member WP users level 1 with a specific start and end date set | |
#change the level (1) below and start (2024-01-01) and end (2024-12-31) dates below and um.meta_value ('%subscriber%') to per your needs | |
INSERT INTO wp_pmpro_memberships_users (user_id, membership_id, code_id, initial_payment, billing_amount, cycle_number, cycle_period, billing_limit,trial_amount,trial_limit, status, startdate, enddate) | |
SELECT | |
u.ID, # ID from wp_users table | |
1, # id of the level to give users | |
0, # code id to give users | |
0, # initial payment to give users | |
0, # recurring amount to give users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add a custom validation to the checkout page. | |
* | |
* @param bool $pmpro_continue_registration | |
*/ | |
function my_custom_validations( $pmpro_continue_registration ) { | |
if ( $pmpro_continue_registration ) { | |
// Check if the user has the level needed. | |
if ( ! empty( $_REQUEST['discount_code'] ) && $_REQUEST['discount_code'] == 'F37910BEB5' && ! pmpro_hasMembershipLevel( '6' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Automatically apply a discount code to Paid Memberships Pro checkout if the user has a specific level ( Interesting for MMPU reasons ) | |
* | |
* Learn more at https://www.paidmembershipspro.com/automatic-discount-code/ | |
* | |
* title: Automatically apply discount code at checkout | |
* layout: snippet-example | |
* collection: discount-codes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add custom columns to PMPro Courses and Lessons in the PMPro Courses Add On counting users having completed lessons and courses | |
* | |
* title: Add custom columns to PMPro Courses and Lessons in the PMPro Courses Add On. | |
* layout: snippet | |
* collection: add-ons | |
* category: wp-list-table | |
* | |
* You can add this recipe to your site by creating a custom plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adjust default emails to show that the user is active for renewals | |
*/ | |
function pmpro_email_filter( $email ) { | |
if( class_exists('PMPro_Approvals') ) { | |
$email_templates = array( 'checkout_paid', 'checkout_check', 'checkout_express' ); | |
//Get the user from the Email object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Bring back hidden levels for those users currently having that level or they had recently. | |
* $hidden_level is the id of the level to bring back. | |
* $end_date_to_compare is the date to compare to determine how much time ago the user had the level. | |
* | |
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function adjusting_the_pmpro_levels_array( $levels ) { | |
$current_user = wp_get_current_user(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Generate a username at PMPro checkout from first and last name for users. | |
* Hide your 'username' field using custom CSS. | |
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_generate_username_at_checkout() { | |
//check for level as well to make sure we're on checkout page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Hook into profile update and send a notification to site admin | |
* | |
* @param int $user_id The ID of the user being updated | |
* @param object $old_user_data The object of the user before it was updated. | |
* @return void | |
*/ | |
function user_profile_update( $user_id, $old_user_data ) { | |
if( class_exists( 'PMProEmail' ) ) { | |
//get the user updated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* https://www.paidmembershipspro.com/avoiding-undefined-function-errors-hooks-filters-custom-code/ | |
* | |
* SUMMARY of article examples | |
* | |
* 1- pmprorh_add_registration_field (Register Helper) | |
* 2- pmpro_has_membership_access (PMPro core) |