Skip to content

Instantly share code, notes, and snippets.

Avatar

Travis Lima travislima

View GitHub Profile
View pmpro-qr-code-avatar.php
<?php
/**
* This recipe replaces a user's avatar with a QR code.
* You can add this recipe to your site by using the Code Snippets plugin available for free in the WordPress repository.
* Follow this guide to add this code to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
* Perform membership actions outputting shortcode content and QR code data.
*/
@travislima
travislima / limit-posts-pmpro-series.php
Last active Mar 26, 2021 — forked from ronalfy/limit-posts-pmpro-series.php
Limit Shown Posts with Paid Memberships Pro Series Add On
View limit-posts-pmpro-series.php
<?php
/**
* CLimit Shown Posts with Paid Memberships Pro Series Add On
* Follow this guide to add this code to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_series_limit_posts_shown( $post_list, $series_object ) {
if ( ! is_user_logged_in() ) {
return $post_list;
@travislima
travislima / woocommerce_billing_fields_pmpro_invoice.php
Last active Mar 26, 2021 — forked from andrewlimaza/woocommerce_billing_fields_pmpro_invoice.php
Add WooCommerce billing fields to Paid Memberships Pro Invoice
View woocommerce_billing_fields_pmpro_invoice.php
<?php
/**
* Adds WooCommerce billing fields to Paid Memberships Pro invoices.
* Follow this guide to add this code to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function add_woocommerce_billing_fields_to_pmpro_invoice() {
global $current_user;
View one_time_trial_delay_pmpro_registration_checks.php
<?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_modal_checkout.php
Last active Apr 14, 2021 — forked from ideadude/pmpro_modal_checkout.php
Example to add a modal checkout popup to every page with Paid Memberships Pro
View pmpro_modal_checkout.php
<?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
View pmpro-assign-levels-to-posts-bulk.php
<?php
/**
* Bulk assign membership levels to posts and pages.
* You will need to adjust the $levels to your desired levels as well as select your desired $post_type.
* Onced added to your site add the following to the end of yout URL in order ro run the script `/wp-admin/?assign_levels_posts=true`
* Add this code to your Customizations Plugin/Code Snippets by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function mypmpro_bulk_assign_levels_to_posts(){
if( isset( $_REQUEST['assign_levels_posts'] ) ){
View pmpro-lpv-track-members.php
<?php
/**
* This code recipe requires the PMPro Limit Post Views Add On: https://www.paidmembershipspro.com/add-ons/pmpro-limit-post-views/
*
* This recipe will track post views for members that have bought a membership.
* Members' views will then be tracked, and if views have exceeded based on their respective
* membership level, they'll be redirected away from the post.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
@travislima
travislima / automatically-approve-previously-approved.php
Last active Dec 3, 2021 — forked from andrewlimaza/automatically-approve-previously-approved.php
Automatically approve, previously approved members. [Paid Memberships Pro]
View automatically-approve-previously-approved.php
<?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 / my_pmprorh_init.php
Last active Feb 6, 2020 — forked from ideadude/my_pmprorh_init.php
Register Helper Field Example - Incomplete Code
View my_pmprorh_init.php
<?php
/*
* Example of Register Helper fields. Code is incomplete. For complete coding solution, please see: https://www.paidmembershipspro.com/documentation/register-helper-documentation/code-examples/
*
*/
// Define the fields.
$fields = array();
$fields[] = new PMProRH_Field(
'company', // input name, will also be used as meta key
@travislima
travislima / rh-example-code.php
Last active Feb 6, 2020
Example of Paid Memberships Pro - Register Helper Code. This code registers the Register Helper Field
View rh-example-code.php
<?php
/*
* EXAMPLE ONLY of Paid Memberships Pro - Register Helper Code.
* Paste new Register Helper Fields above this line(s) of code in your PMPro Customizations Plugin
*/
$fields = array(); // this line should not be added a second time if you have previously declared it which i believe you have if you are trying to use this code recipe
$fields[] = new PMProRH_Field(
'field_name', // input name, will also be used as meta key