Skip to content

Instantly share code, notes, and snippets.

View travislima's full-sized avatar

Travis Lima travislima

View GitHub Profile
@travislima
travislima / one_time_trial_delay_pmpro_registration_checks.php
Last active September 5, 2024 13:10 — forked from kimcoleman/one_time_trial_delay_pmpro_registration_checks.php
Offer one-time trials using the Subscription Delays Add On
<?php
/**
* This code stores data when a user checks out for a level.
* If that user tries to checkout for the same level, the Subscription Delay is removed.
* The user is instead charged for their first subscription payment at checkout.
*
*/
// Record when users gain the trial level.
function one_time_trial_save_trial_level_used( $level_id, $user_id ) {
@travislima
travislima / pmpro_change_pay_by_check.php
Last active January 24, 2024 13:44
Change "Pay by Check" to "Pay by Cheque or Bank Transfer"
<?php
/**
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
* A simple gist that changes "Pay by Check" to "Pay by Cheque or Bank Transfer:".
* Copy the code below into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Pay by Check' :
@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 / hide-pmpro-username.css
Last active March 24, 2023 19:59
Hide the Paid Memberships Pro Username field using CSS
/*
*
* The following CSS code will hide the PMPro username field, label and the required asterisk.
* Add this CSS to your WordPress Customizer's Additional CSS section (WP Dashboard > Appearance > Customizer > Additional CSS)
* Code Recipe intended to be used along with the following gist: https://gist.github.com/travislima/4d599cc0b6169ef7ee7514442f289123
*
*/
.pmpro_checkout-field-username {
display: none;
@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 / pmpro-grace-period.php
Last active October 12, 2022 16:52
Add a "Grace Period" to a Paid Memberships Pro Membership (After expiration date is met).
<?php
/*
* The Code Recipe will add a 15-day grace period to a members membership once the membership expires.
* Add this Code Recipe to a PMPro Customization Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* For more information on Paid Memberships Pro - www.paidmembershipspro.com
*/
function my_pmpro_membership_post_membership_expiry( $user_id, $level_id ) {
// Make sure we aren't already in a grace period for this level
$grace_level = get_user_meta( $user_id, 'grace_level', true );
@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 / pmpro_rh_step3.php
Last active March 16, 2022 13:10
Step 3 - Register Helper: A step-by-step guide on creating custom fields.
<?php //Do not copy this tag.
/**
* Add custom fields to Paid Memberships Pro checkout page.
* Must have PMPro & Register Helper Add On installed and activated to work.
* Add this code to a PMPro Customizations Plugin or Code Snippets plugin.
*/
function pmpro_add_fields_to_checkout(){
//don't break if Register Helper is not loaded