Skip to content

Instantly share code, notes, and snippets.

View travislima's full-sized avatar

Travis Lima travislima

View GitHub Profile
@travislima
travislima / hide_post_thumbnail_on_restricted_content.php
Last active April 7, 2021 03:33 — forked from kimcoleman/hide_post_thumbnail_on_restricted_content.php
Do not return the post thumbnail (featured image) on restricted content when viewed by a non-member.
<?php
/**
* Do not return the post thumbnail (featured image) on restricted content when viewed by a non-member.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
*
*/
function hide_post_thumbnail_on_restricted_content( $html, $post_id, $post_image_id ) {
if ( function_exists( 'pmpro_has_membership_access' ) ) {
@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 / 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 / generate-field-data-for-specific-levels.php
Created February 19, 2019 11:08 — forked from andrewlimaza/generate-field-data-for-specific-levels.php
Generate fields for free membership levels, or specific levels.
<?php
/**
* This will generate information for username, password and password 2. This is great for free levels.
* Adjust the $generate_data_level ID's to allow data generation for specific levels.
* Use CSS to hide these fields on the checkout page from the frontend.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Function to make fields optional for free levels.
function my_generate_fields_for_users() {
@travislima
travislima / load-my-script-pmpro.php
Last active April 8, 2021 18:23 — forked from andrewlimaza/load-my-script-pmpro.php
Load content on confirmation or checkout page for PMPro.
<?php
/**
* Load content for specific pages, checkout or confirmation page
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function load_my_script_for_pmpro() {
global $pmpro_pages;
if ( is_page( $pmpro_pages['checkout'] ) || is_page( $pmpro_pages['confirmation'] ) || is_page( $pmpro_pages['account'] ) || is_page( $pmpro_pages['billing'] ) || is_page( $pmpro_pages['cancel'] ) || is_page( $pmpro_pages['invoice'] ) || is_page( $pmpro_pages['levels'] ) || is_page( $pmpro_pages['popup-cvv'] ) ) {
?>
@travislima
travislima / add-shipping-address-to-admin-order.php
Created February 5, 2019 11:15 — forked from andrewlimaza/add-shipping-address-to-admin-order.php
Add Shipping Address Details To Admin Order View
<?php
/**
* This will add Shipping Address information when an admin view's the user's order in the WordPress dashboard.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_shipping_address_to_admin_order_view( $order ) {
$user_id = $order->user_id;
<?php
/**
* Add the following code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations
* In this example you will learn how to add 3 checkboxes to Paid Memberships Pro Checkout page.
*/
function rh_fields_example_checkbox()
{
//don't break if Register Helper is not loaded
@travislima
travislima / my-pmpro-valid-shipping-zip-codes.php
Last active September 2, 2025 15:17 — forked from andrewlimaza/my-pmpro-valid-shipping-zip-codes.php
Only allow shipping to specific Zip Codes for Paid Memberships Pro Shipping.
<?php
/**
* This will only allow users to checkout with specific zip codes for the Shipping Add On for Paid Memberships Pro.
* You will need to use this code recipe together with the PMPro Shipping Address Add On - https://www.paidmembershipspro.com/add-ons/shipping-address-membership-checkout/
* Add the code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_valid_zip_codes( $pmpro_continue_registration ) {
@travislima
travislima / pmpro-add-post-type-to-series.php
Created December 3, 2018 11:41 — forked from andrewlimaza/pmpro-add-post-type-to-series.php
Add a Custom Post Type for PMPro Series Add On
<?php
/**
* This allows PMPro Series to take new post types, such as a Custom Post Type.
* Add the code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_add_post_type_to_series( $post_types ) {
$post_types[] = 'my_cpt_name';
return $post_types;
<?php
/**
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Change the default Country for Paid Memberships Pro - https://www.paidmembershipspro.com
* Find Country Codes here - https://github.com/strangerstudios/paid-memberships-pro/blob/dev/includes/countries.php
*/
function filter_pmpro_default_country( $default_country ) {
// Set country code to "GB" for United Kingdom.