Skip to content

Instantly share code, notes, and snippets.

View ideadude's full-sized avatar

Jason Coleman ideadude

View GitHub Profile
@ideadude
ideadude / my_pmpro_show_cvv.php
Created July 13, 2020 23:31
Remove CVV from the checkout page and don't require it.
<?php
/**
* Remove CVV from the checkout page and don't require it.
*/
// Removes the field from the checkout page.
function my_pmpro_show_cvv( $show ) {
return false;
}
add_filter( 'pmpro_show_cvv', 'my_pmpro_show_cvv' );
@ideadude
ideadude / my_pmpro_member_number_field.php
Last active July 13, 2020 19:15
Add a "member_number" field that only admins can edit using PMPro and Register Helper.
<?php
/**
* Add a "member_number" field that only admins can edit.
* Make sure PMPro and the Register Helper Add On are active.
* Copy this code into a Code Snippet or custom plugin.
*/
function my_pmpro_member_number_field() {
// Don't break if Register Helper is not loaded.
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
@ideadude
ideadude / shareasale_pmpro_affiliates.html
Created July 13, 2020 18:15
Share a Sale Tracking Code to use with PMPro Affiliates.
<img id='_SHRSL_img_1' src='https://www.shareasale.com/sale.cfm?tracking=!!ORDER_ID!!&amount=!!ORDER_AMOUNT!!&merchantID=XXXXX&transtype=sale' width='1' height='1'>
<script src='https://www.dwin1.com/19038.js' type='text/javascript' defer='defer'></script>
@ideadude
ideadude / pmprorh-init-buddypress-fields.php
Created July 2, 2020 12:14 — forked from pbrocks/pmprorh-init-buddypress-fields.php
Example of defining PMPro Register Helper Fields Synchronized to BuddyPress XProfile Fields
<?php
/**
* Based on the Register Helper example.
* We've added a "buddypress" option for each field
* set to the XProfile name we used when setting up
* the fields in the BuddyPress extended profile.
* If the PMPro BuddyPress Add On is activated
* then the fields will be synchronized.
* Register Helper: https://www.paidmembershipspro.com/add-ons/pmpro-register-helper-add-checkout-and-profile-fields/
* PMPro BuddyPress: https://www.paidmembershipspro.com/add-ons/buddypress-integration/
@ideadude
ideadude / my_pmprowoo_is_purchasable.php
Created July 1, 2020 22:39
Change the default PMPro WooCommerce bahavior and make membership products not purchasable if a user already has any other membership level.
<?php
/**
* Change the default PMPro WooCommerce bahavior
* and make membership products not purchasable
* if a user already has any other membership level.
*/
// First disable the core PMPro WC callaback and set up our own.
function my_pmprowoo_init() {
remove_filter( 'woocommerce_is_purchasable', 'pmprowoo_is_purchasable', 10, 2 );
add_filter( 'woocommerce_is_purchasable', 'my_pmprowoo_is_purchasable', 5, 2 );
@ideadude
ideadude / my_fix_wpelogin.php
Created June 29, 2020 20:40
Make sure to add the wpe-login parameter to the lostpassword URL.
<?php
/**
* Make sure to add the wpe-login parameter to the lostpassword URL.
*/
function my_fix_wpelogin( $url ) {
$url = add_query_arg( 'wpe-login', true, $url );
return $url;
}
add_filter( 'lostpassword_url', 'my_fix_wpelogin' );
@ideadude
ideadude / my_amlbofat_save_function.php
Last active March 27, 2021 00:14
Assign additional membership levels based on fields at checkout.
<?php
/**
* Assign additional membership levels based on fields at checkout.
* Requires PMPro, PMPro MMPU, and PMPro Register Helper.
* This is just an example. Be sure to change the field settings,
* field meta name, and membership levels to fit your needs.
*/
// Add a checkbox via Register Helper
function my_amlbofat_add_fields() {
@ideadude
ideadude / PMPRO_LICENSE_NAG.php
Created June 18, 2020 16:51
Disable the PMPro license nag.
<?php
// Add this to your wp-config.php file.
define('PMPRO_LICENSE_NAG', false);
@ideadude
ideadude / pmpro_required_fields.css
Created June 11, 2020 13:22
CSS to show the word "Required" next to the asterisks on the checkout form.
span.pmpro_asterisk:after { content: "Required" }
@ideadude
ideadude / my_lockdown_files_by_media_category.php
Created June 3, 2020 20:51
Restrict files in the media library based on media category when using Paid Memberships Pro and Media Library Categories
<?php
/**
* Restrict files in the media library based on media category.
* Required plugins:
* - Paid Memberships Pro
* - Media Library Categories
* Must have PMPro set up to run files through the getfile.php script.
* See this post: https://www.paidmembershipspro.com/locking-down-protecting-files-with-pmpro/
* Add a 'members' category or adjust the code below to use your categories.
*/