Skip to content

Instantly share code, notes, and snippets.

View travislima's full-sized avatar

Travis Lima travislima

View GitHub Profile
@travislima
travislima / pmpro_frontend-oldschool.css
Last active April 12, 2021 22:27 — forked from kimcoleman/pmpro_frontend-oldschool.css
Return the style of labels and form inputs on the Membership Checkout form to pre-1.9.4 layout using Paid Memberships Pro
<style>
@media only screen and (min-width: 1200px) {
#pmpro_form h3 {
display: grid;
grid-template-columns: 2fr 1fr;
}
.pmpro_checkout .pmpro_checkout-fields .pmpro_checkout-field {
clear: left;
}
.pmpro_checkout .pmpro_checkout-fields .pmpro_checkout-field label {
@travislima
travislima / pmpro_registration_checks_no_email_user_login.php
Created January 12, 2018 12:37 — forked from ideadude/pmpro_registration_checks_no_email_user_login.php
Stop users from setting their username to an email address with Paid Memberships Pro
/*
Stop users from setting their username to an email address
Add this code to a custom plugin.
*/
function pmpro_registration_checks_no_email_user_login($continue) {
//if there are earlier problems, don't bother checking
if(!$continue)
return;
//make sure the username passed in doesn't look like an email address (contains a @)
@travislima
travislima / pmpro-south_african-vat.php
Last active April 24, 2020 15:59 — forked from strangerstudios/pmpro-australia-gst.php
Paid Memberships Pro - South African VAT Plugin (DEVELOPING)
<?php
/*
Plugin Name: Paid Memberships Pro - South Africa VAT
Plugin URI: TBA
Description: Apply South Africa VAT to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@travislima
travislima / pmpro-open-comments-non-members.php
Last active April 8, 2021 18:22 — forked from andrewlimaza/pmpro-open-comments-non-members.php
Open comments so anyone may read them
<?php
/**
* Allows non-members to read comments on restricted posts.
* Add the code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function make_pmpro_comments_open() {
remove_filter( 'comments_array', 'pmpro_comments_filter', 10, 2 );
}
add_action( 'init', 'make_pmpro_comments_open' );
@travislima
travislima / first-time-login-redirect.php
Created April 10, 2018 03:14 — forked from andrewlimaza/first-time-login-redirect.php
First Time Login Redirect For Paid Memberships Pro
<?php
/**
* Redirect a member for first time login.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* www.paidmembershipspro.com
*/
function first_time_login_redirect( $redirect_to, $request, $user ) {
//check level
if ( ! empty( $user ) && ! empty( $user->ID ) && function_exists( 'pmpro_getMembershipLevelForUser' ) ) {
@travislima
travislima / stop-non-pmpro-members-from-buying-woocommerce.php
Last active April 12, 2021 20:23 — forked from andrewlimaza/stop-non-pmpro-members-from-buying-woocommerce.php
Make certain WooCommerce products not-purchasable for non-members
<?php
/**
* Stop non-members from purchasing products if they do not have an active Paid Memberships Pro Level.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function stop_non_pmpro_members_from_buying_woo( $is_purchasable, $product ) {
// Check if the user has an active membership level.
@travislima
travislima / remove_member_homepages_redirect.php
Last active April 12, 2021 20:22 — forked from andrewlimaza/remove-homepage-replacement.php
Remove homepage replacement for admins only (Paid Memberships Pro HomePages Add On)
<?php
/**
* Remove the replacement homepage from the Member HomePages Add On for Paid Memberships Pro.
*
* Add this code (L7-L12 only) to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function remove_member_homepages_redirect(){
if ( current_user_can( 'manage_options' ) ) {
remove_action( 'template_redirect', 'pmpromh_template_redirect_homepage' );
}
@travislima
travislima / pmpro-adjust-price-for-members.php
Last active April 12, 2021 20:20 — forked from andrewlimaza/pmpro-adjust-price-for-members.php
Adjust checkout pricing for existing members for Paid Memberships Pro.
<?php
/**
* This will adjust membership pricing depending on users current level and level checking out for. See line 10.
* This will show you how to adjust the initial amount and/or the recurring amount. If the existing level, in this case 2, is not a recurring level please uncomment lines 12-14.
* Add this code (L8 - L20) to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function pmpro_adjust_price_for_members( $level ) {
// Adjust price for existing members that currently have Membership level id 1 and are upgrading to Membership Level id 2.
@travislima
travislima / add-text-before-submit-button-example.php
Last active April 12, 2021 20:19 — forked from andrewlimaza/add-text-before-submit-button-example.php
Add text before submit button in Paid Memberships Pro
<?php
/**
* Adds text before the submit button on the checkout page.
* Add this code below to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function add_text_before_submit() {
echo 'Hello! This will add some <a href="#" target="_blank">information</a> to your site for you.';
}
add_action( 'pmpro_checkout_before_submit_button', 'add_text_before_submit' );
@travislima
travislima / my_gettext_membership.php
Last active May 22, 2018 12:04 — forked from andrewlimaza/my_gettext_membership.php
Change "Membership" to a different word with Paid Memberships Pro
// Change 'Membership' to 'Subscription' for Paid Memberships Pro.
function my_gettext_membership( $translated_text, $text, $domain ) {
if( "paid-memberships-pro" == $domain ) {
$translated_text = str_replace( "Membership Level", "Subscription", $translated_text );
$translated_text = str_replace( "membership level", "subscription", $translated_text );
$translated_text = str_replace( "membership", "subscription", $translated_text );
$translated_text = str_replace( "Membership", "Subscription", $translated_text );
}
return $translated_text;
}