Skip to content

Instantly share code, notes, and snippets.

View travislima's full-sized avatar

Travis Lima travislima

View GitHub Profile
@travislima
travislima / my_pmprowoo_get_membership_price.php
Last active December 20, 2023 03:23 — forked from andrewlimaza/my_pmprowoo_get_membership_price.php
Use the pmprowoo_get_membership_price filter to set prices for variable products with Paid Memberships Pro and WooCommerce
<?php
/**
* Use the pmprowoo_get_membership_price filter to set prices for variable products.
* Update the $membership_prices array.
* Each item in that array should have a key equal to the membership level id,
* and a value equal to an array of the form array( {variable_product_id} => {member_price} )
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprowoo_get_membership_price( $discount_price, $level_id, $original_price, $product ) {
// Setup your arrays of product ids to membership prices.
@travislima
travislima / show-renewal-link-after-X-days-or-less.php
Last active March 24, 2023 18:09 — forked from andrewlimaza/show-renewal-link-on-30-days-or-less.php
Change when to show the renewal link on Paid Memberships Pro account page.
@travislima
travislima / first-time-login-redirect.php
Created April 10, 2018 03:14 — forked from andrewlimaza/first-time-login-redirect.php
First Time Login Redirect For Paid Memberships Pro
<?php
/**
* Redirect a member for first time login.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* www.paidmembershipspro.com
*/
function first_time_login_redirect( $redirect_to, $request, $user ) {
//check level
if ( ! empty( $user ) && ! empty( $user->ID ) && function_exists( 'pmpro_getMembershipLevelForUser' ) ) {
@travislima
travislima / pmpro_modal_checkout.php
Last active November 7, 2022 16:36 — forked from ideadude/pmpro_modal_checkout.php
Example to add a modal checkout popup to every page with Paid Memberships Pro
<?php
/**
* Define the default level to use for the modal
*/
define('PMPRO_MODAL_CHECKOUT_DEFAULT_LEVEL', 1);
/**
* Load the checkout preheader on every page
* We won't be processing on every page, but we
* want the code that sets up the level and
@travislima
travislima / stop-renewing-members.php
Created February 26, 2019 08:20 — forked from andrewlimaza/stop-renewing-members.php
Stop members from renewing their current membership level [Paid Memberships Pro].
<?php
/**
* Stop members from renewing their current membership level.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function stop_members_from_renewing( $okay ) {
// If something else isn't okay, stop from running this code further.
if ( ! $okay ) {
@travislima
travislima / my_pmpro_login_redirect_url.php
Last active March 15, 2022 03:30 — forked from messica/my_pmpro_login_redirect_url.php
Redirect on login if user has any failed payments. (Requires Paid Memberships Pro Failed Payment Limit Add On)
<?php
/*
* Redirect on login if user has any failed payments. (Requires Paid Memberships Pro Failed Payment Limit Add On)
* Adjust the code on the line the line "site_url( ' payment-failed')" to redirect to page of your prefereance.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_login_redirect_url( $url, $request, $user ) {
@travislima
travislima / load-custom-css-level-pmpro.php
Last active February 1, 2022 14:23 — forked from andrewlimaza/load-custom-css-level-pmpro.php
Load custom CSS for Membership Checkout for specific level - Paid Memberships Pro
<?php
/**
* Load custom CSS on checkoutpage for specific membership level in Paid Memberships Pro.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function load_css_for_level_checkout(){
global $pmpro_pages;
// Change your membership level ID here.
@travislima
travislima / pmpro-renew-membership-shortcode.php
Last active December 22, 2021 20:22 — forked from andrewlimaza/pmpro-renew-membership-shortcode.php
Paid Memberships Pro Renew Membership Shortcode
<?php
/**
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* The my_pmpro_renew_membership_shortcode is a custom function creating a renew link for members.
* Use the shortcode [pmpro_renew_button] to display the button anywhere on your site where shortcodes are recognized.
*
* @return string A link containing the URL string to renew.
*/
@travislima
travislima / automatically-approve-previously-approved.php
Last active December 3, 2021 14:38 — forked from andrewlimaza/automatically-approve-previously-approved.php
Automatically approve, previously approved members. [Paid Memberships Pro]
<?php
/**
* Automatically approve any previously approved member.
* Requires the PMPro Approval Process for Membership Add On - https://www.paidmembershipspro.com/add-ons/approval-process-membership/
* Add this code to your site following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_automatically_approve_previously_approved( $level_id, $user_id, $cancelled_level ) {
if ( ! class_exists( 'PMPro_Approvals' ) ) {
@travislima
travislima / exclude-discount-woocommerce-categories.php
Created July 23, 2019 11:31 — forked from andrewlimaza/exclude-discount-woocommerce-categories.php
Exclude membership discount for products in a certain category for WooCommerce and Paid Memberships Pro.
<?php
/**
* This will exclude products that belong to a specific category from the membership discount.
* Add the below code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_exclude_woocommerce_discounts_for_categories( $price, $level_id, $original_price, $product ) {
// Array of categories to exclude, uses category slug.
$exclude_categories = array( 'category-1', 'category-2', 'category-3' );