Skip to content

Instantly share code, notes, and snippets.

View travislima's full-sized avatar

Travis Lima travislima

View GitHub Profile
@travislima
travislima / pmpro-select-membership-duration.php
Last active April 8, 2021 22:10 — forked from greathmaster/pmpro-select-membership-duration.php
Allows customers to select membership duration at checkout. Adjusts the amount charged and expiration date of the membership accordingly.
<?php
/**
* Allow customers to select membership duration at checkout. Adjust the amount charged and expiration date of the membership accordingly.
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* Requires the Paid Memberships Pro Register Helper Add On to be installed and activated in order to work:
* https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
*/
@travislima
travislima / pmpro-group-discount-order-csv-export.php
Last active April 8, 2021 20:42 — forked from greathmaster/pmpro-group-discount-order-csv-export.php
Add the group code column to the Order CSV export
<?php //Do not copy this PHP tag into your code.
/**
* Adds an extra colum to your Memberships > Orders > Export to CSV file. Displays the group discount code used.
*
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
* Requires the Paid Memberships Pro Group Discount code Add On to be installed and activated in order to work:
* https://www.paidmembershipspro.com/add-ons/group-discount-codes/
*/
@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 / pmpro-lpv-add-my-post-types.php
Last active April 8, 2021 18:29 — forked from andrewlimaza/pmpro-lpv-add-my-post-types.php
Add "Pages" to PMPro Limit Post Views
<?php // Careful not to copy this php tag.
/**
* Add 'pages' for Limit Post Views Add On for Paid Memberships Pro. You may also add your custom post types using this function below.
* Requires the Paid Memberships Pro - Limit Post Types Add On to work: https://www.paidmembershipspro.com/add-ons/pmpro-limit-post-views/
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_lpv_add_my_post_types( $post_types ) {
// Add pages to post type array to restrict Limit Post Views.
$post_types[] = 'page';
@travislima
travislima / replace_spaces_with_underscores.php
Last active August 8, 2018 15:11 — forked from andrewlimaza/replace_spaces_with_underscores.php
Replace spaces with underscore "_" for usernames.
<?php // Do not copy this tag.
/**
* Replace all spaces with an underscore when new users register for Paid Memberships Pro.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_custom_user_registration_changes( $userdata ) {
$userdata['user_login'] = str_replace(' ', '_', $userdata['user_login'] );
@travislima
travislima / my_init_email_as_username.php
Created August 21, 2018 09:28 — forked from strangerstudios/my_init_email_as_username.php
Use the email address as username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template.
<?php
function my_init_email_as_username()
{
//check for level as well to make sure we're on checkout page
if(empty($_REQUEST['level']))
return;
if(!empty($_REQUEST['bemail']))
$_REQUEST['username'] = $_REQUEST['bemail'];
@travislima
travislima / shortcode_membership_name.php
Last active September 4, 2018 11:52 — forked from andrewlimaza/shortcode_membership_name.php
Membership level name shortcode for Paid Memberships Pro
<?php //Do not copy this tag.
// Copy the function below into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
// Use the shortcode [membership_level] to display the user's current membership level.
function pmpro_membership_level_shortcode( $atts ){
if(is_user_logged_in() && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel()){
global $current_user;
$current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID);
return sprintf(__( "Your current level is: %s", "pmpro" ), $current_user->membership_level->name);
@travislima
travislima / change-recurring-payment-reminder.php
Last active April 8, 2021 18:49 — forked from andrewlimaza/change-recurring-payment-reminder.php
Change when recurring payment reminders are sent for Paid Memberships Pro.
<?php // Do not copy this PHP tag.
/**
* Send recurring subscription payment email reminder 14 days before subscription payment.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_recurring_emails( $emails ) {
// Remove the email that is sent 7 days before subscription payment.
unset( $emails[7] );
@travislima
travislima / send-invoice-after-checkout.php
Created October 11, 2018 10:18 — forked from andrewlimaza/send-invoice-after-checkout.php
Send an invoice email after user signs up for a membership - Paid Memberships Pro
<?php
/**
* Send the Paid Memberships Pro invoice email on initial checkout for members.
* Add this code below into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_after_checkout_send_invoice_email( $user_id, $order ) {
$email = new PMProEmail();
$email->sendInvoiceEmail( $user_id, $order );
}
@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.