Skip to content

Instantly share code, notes, and snippets.

@ideadude
ideadude / my_pmprowoo_woocommerce_product_is_on_sale.php
Created June 15, 2018 19:24
Consider member prices a "sale" so regular price is shown with a strikethrough with WooCommerce and PMPro WooCommerce
/**
* Consider member prices a "sale" so regular price is shown with a strikethrough
* If PMPro WooCommerce is active and setup to discount prices,
* then the calls to $product->get_price() will be filtered to return
* the member price.
*
* Add this code to a custom plugin.
*/
function my_pmprowoo_woocommerce_product_is_on_sale( $on_sale, $product ) {
$regular_price = (float) $product->get_regular_price();
@andrewlimaza
andrewlimaza / filter-woo-store-membership-levels-pmpro.php
Last active July 2, 2024 13:06
Filter your WooCommerce store according to membership level for Paid Memberships Pro.
<?php
/**
* This code recipe will allow you to hide products on the shop page by their category according to user's membership levels.
* This example uses category-1, category-2 and category-3 as category examples.
* This code will also stop users from purchasing products if they manage to find these products directly.
* Add this code (from line 2) to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
/**
@pbrocks
pbrocks / pmpro-cancel-on-next-payments-date.php
Last active July 17, 2019 14:26 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
<?php
/**
* Change cancellation to set expiration date for next payment instead of cancelling immediately.
*
* Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
*
* Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
/**
@kimcoleman
kimcoleman / elementor_compatibility_for_pmpro.php
Last active February 4, 2025 15:48
Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder.
<?php
/**
* Ensure Paid Memberships Pro compatibility when using the Elementor Page Builder:
* https://wordpress.org/plugins/elementor/
*
* Your administrator-level account must have a Membership Level in order to edit all of the pages assigned
* under Memberships > Pages.
*
* You must also set a Custom Field on the Membership Checkout page with the key 'pmpro_default_level' and
* value of a level ID in order to properly edit your Membership Checkout page using Elementor.
@andrewlimaza
andrewlimaza / make_lower_product_not_purchasable.php
Created February 12, 2018 09:04
Stop users from purchasing a lower membership level Paid Memberships Pro WooCommerce
<?php
/**
* This stops users from purchasing a lower level membership through WooCommerce. (Assume lower level ID is '1')
* If user has level 2 or 3, stop them from purchasing level 1 membership.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Stop users from purchasing a lower membership level via WooCommerce.
function pmpro_lower_level_is_purchasable( $is_purchasable, $product ) {
@kimcoleman
kimcoleman / legacy_my_pmpro_payment_method.css
Last active July 22, 2024 13:14 — forked from strangerstudios/my_pmpro_payment_method.css
Legacy for PMPro pre-v3.1. Not compatible with PMPro v3.1+. Adds credit card logos and a PayPal logo to the "Select Payment Method" box on membership checkout.
/* CSS Document */
#pmpro_payment_method span a {
background-position: left bottom;
background-size: contain;
background-repeat: no-repeat;
display: inline-block;
margin-left: 1%;
max-width: 300px;
padding-bottom: 60px;
text-align: left;
@xujiaao
xujiaao / android-set-ntp-server.md
Last active October 19, 2025 20:37
Set the NTP server of your android device
tags
Android
Android Things

Set the NTP server of your android device

@andrewlimaza
andrewlimaza / restrict_woo_product_non_members.php
Last active July 2, 2019 22:32
Restrict particular product for WooCommerce and Paid Memberships Pro
<?php
/**
* This function allows you to restrict a single WooCommerce product to non-members (disables add to cart button)
* Price will still be displayed.
* Add the following code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function hide_add_to_cart_for_non_members( ){
@andrewlimaza
andrewlimaza / redirect_users_to_a_new_page.php
Created July 4, 2017 14:49
Redirect users away from 'account' page in PMPro if they do not have a membership/logged-in
<?php
/**
* Redirect user's to a new URL instead of the 'levels' page in PMPro.
* Add this code to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function redirect_users_to_a_new_page( $url ){
return 'https://some-url.com'; //change this to the URL you would like to redirect your user's to.
@andrewlimaza
andrewlimaza / pmpro-edit-other-emails.php
Last active August 20, 2020 12:31
Stop PMPro from editing other WordPress email formats. Remove email filter.
remove_filter( 'wp_mail_content_type', 'pmpro_wp_mail_content_type' );