Skip to content

Instantly share code, notes, and snippets.

View lubyagin's full-sized avatar

Александр lubyagin

View GitHub Profile
@andrewlimaza
andrewlimaza / pmpro_redirect_validate_per_level.php
Last active February 19, 2019 23:25
Redirect to a specific URL when a user uses email confirmation for PMPro for a certain level.
<?php
/**
* Redirect to URL depending on which level a user is validating for.
* Checks to see if a user currently has a level which will return true if logged in, if user is not logged in redirect them to login.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmproec_after_validate_user() {
if( pmpro_hasMembershipLevel( 1 ) ) {
wp_redirect("/level-1-url/");
@andrewlimaza
andrewlimaza / make_discount_code_bold.css
Created September 7, 2017 07:53
Make PMPro discount code text bold
#other_discount_code_p{font-weight: bold;}
@andrewlimaza
andrewlimaza / pmpro-canada-tax.php
Last active July 28, 2021 10:11
Apply tax for Canada PMPro example.
<?php
/**
* Apply 13% if a user selects 'Canada'.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Set 13% tax value.
function customtax_pmpro_tax($tax, $values, $order) {
$tax = round( (float)$values[price] * 0.13, 2 );
@andrewlimaza
andrewlimaza / pmpro_numbers_only_checkout.php
Created August 14, 2017 07:57
Restrict PMPro checkout fields to only use numbers.
<?php
/**
* The following code restricts the following fields to only accept numbers for input - Phone, Credit Card and CVV.
* Add the function below to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* For assistance visit https://www.paidmembershipspro.com
*/
function pmpro_numbers_only_checkout() {
?>
<script>
@andrewlimaza
andrewlimaza / user_login_level.php
Created August 8, 2017 11:37
Get user level when logging in for PMPro
<?php
// Add this function below to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function get_membership_on_login( $user_login, $user ) {
$level = pmpro_getMembershipLevelForUser( $user->ID );
// if it's not empty assume user has a level.
if( !empty( $level ) ){
@strangerstudios
strangerstudios / pmpro-customizations.php
Created August 3, 2017 15:46
A blank plugin file for customizations to your Paid Memberships Pro setup including a stylesheet for customizations.
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for my Paid Memberships Pro Setup
Version: .1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
*/
@andrewlimaza
andrewlimaza / html_instructions_pay_by_check.php
Created July 31, 2017 14:23
Add your own HTML instructions to Pay By Check PMPro.
<?php
/**
* This is an example how to add custom HTML instructions for Pay By Check add-on for Paid Memberships Pro
* Copy the following code into your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit www.paidmembershipspro.com
*/
function add_custom_checkout_instructions_to_pmpro_check() {
global $gateway, $pmpro_level;
@andrewlimaza
andrewlimaza / pmpro_allow_access_for_admins.php
Last active February 4, 2025 06:57
Allow admins, administrator, administrators access to all restricted posts in WordPress with Paid Memberships Pro
<?php
/**
* This code snippet allows admins without any PMPro membership level to access any restricted content.
* Add this code to your PMPro Customizations plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmmpro_allow_access_for_admins($hasaccess, $mypost, $myuser, $post_membership_levels){
//If user is an admin allow access.
if( current_user_can( 'manage_options' ) ){
@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 / change_postal_code_to_zip_code.php
Created June 29, 2017 12:06
Change postal code to zip code in PMPro
<?php
/**
* This function changes all instances of 'Postal Code' to 'Zip Code' for Paid Memberships Pro.
* Add this code to your PMPro Customizations plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit www.paidmembershipspro.com
*/
function pmpro_change_postal_code_text( $translated_text, $text, $domain ){