Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Lima andrewlimaza

View GitHub Profile
@andrewlimaza
andrewlimaza / all-access-pmproap-level-4.php
Created May 3, 2021
Grant user's with level 4 access to all Addon Packages
View all-access-pmproap-level-4.php
<?php
/**
* Give user's with level ID 4 free access to all Addon Packages content.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmproap_all_access_levels( $levels ) {
$levels = array( 4 ); //change the level ids here
return $levels;
}
add_filter( "pmproap_all_access_levels", "my_pmproap_all_access_levels" );
@andrewlimaza
andrewlimaza / mmpu-woocommerce-enable.php
Created Apr 29, 2021
Allow user's to hold multiple levels with MMPU and WooCommerce for Paid Memberships Pro.
View mmpu-woocommerce-enable.php
<?php
/**
* This allows user's to have multiple levels when purchasing via WooCommerce.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_filter( 'pmprowoo_mmpu_force_add_level', '__return_true' );
@andrewlimaza
andrewlimaza / pmpro-redirect-non-members.php
Created Apr 29, 2021 — forked from strangerstudios/pmpro-redirect-non-members.php
Paid Memberships Pro Redirect Non-members to Login/Homepage
View pmpro-redirect-non-members.php
<?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 / pmpro-members-invoice-adjust-order-print.css
Created Apr 28, 2021
Adjust what is printed for the Paid Memberships Pro Members Invoice page
View pmpro-members-invoice-adjust-order-print.css
/**
* Add this code to your WordPress Customizer under "Additional CSS".
* Tweak the CSS on both areas to hide and show certain elements when printing the Members Invoice.
*/
@media print {
/** Hide stuff when printing **/
.pmpro-invoice .site-header, .pmpro-invoice .pmpro_actions_nav, .pmpro-invoice footer {
display:none;
}
@andrewlimaza
andrewlimaza / pmpro-add-sponsored-discount-code-zapier.php
Last active Apr 23, 2021
Add Sponsored Member's Code to Zapier Data [Paid Memberships Pro]
View pmpro-add-sponsored-discount-code-zapier.php
<?php
/**
* Add Sponsored discount code to Paid Memberships Pro Zapier Integration data.
* This runs on the "After Checkout" trigger. Requires Sponsored/Group Members Add On - https://www.paidmembershipspro.com/add-ons/pmpro-sponsored-members/
* Add this code to your site by following
*/
function my_pmpro_add_sponsored_code_zapier( $data, $user_id, $level, $order ){
// Bail if Sponsored Members not available.
@andrewlimaza
andrewlimaza / dynamic-read-only-field-type-rh-pmpro.php
Last active May 6, 2021
dynamic readonly example for Register Helper
View dynamic-read-only-field-type-rh-pmpro.php
<?php
/**
* Make read-only set to true for non-admins.
* This is a template, please copy code over that is needed for your own integrations.
* Follow this guide to add custom code to your membership site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprorh_init() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
@andrewlimaza
andrewlimaza / remove-now-from-cost-text-pmpro.php
Created Apr 15, 2021
Remove the word "now" from Paid Memberships Pro level cost text.
View remove-now-from-cost-text-pmpro.php
<?php
/**
* Hide the word "now" from the level cost text (price) of a membership level.
* If you need more functionality, consider using this Add On - https://www.paidmembershipspro.com/add-ons/pmpro-custom-level-cost-text/
* Add this code to your site by following - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_remove_now_from_cost_text( $cost, $level, $tags, $short ) {
$cost = str_replace(" now", "", $cost);
return $cost;
@andrewlimaza
andrewlimaza / pmpro-qr-code-sponsored-member.php
Last active Apr 13, 2021
Sponsored members checkout URL when scanning QR code [Paid Memberships Pro]
View pmpro-qr-code-sponsored-member.php
<?php
/**
* If a user is a parent/sponsor member, set the QR code to the child checkout URL.
* This will get the first sponsored level checkout URL and discount code.
* Only set the QR code to the checkout URL if there are available seats.
* Add this code to your site by visiting - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_membership_card_sponsored_members( $card_user, $option ) {
@andrewlimaza
andrewlimaza / pmpro-checkout-compatibility-wpml.php
Last active Apr 13, 2021
WPML Compatibility for Paid Memberships Pro Checkout.
View pmpro-checkout-compatibility-wpml.php
<?php
/**
* Adds support for plugins like WPML that create pages for translation.
* Improves the pmpro_is_checkout() calls to try and make it 'smarter'.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_wpml_checkout_compat( $is_checkout ) {
// If we're already on checkout, just bail.
@andrewlimaza
andrewlimaza / change-expiration-until-cancelled.php
Created Apr 12, 2021
Change Expiration Text From "---" to "Until Cancelled"
View change-expiration-until-cancelled.php
<?php
/**
* Change the account page expiration text to "Until Cancelled"
* for never expiring levels/members.
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_adjust_expiration_text( $expiration_text, $level ) {
if ( $expiration_text === '---' ) {
$expiration_text = __( 'Until Cancelled', 'paid-memberships-pro' );
}