Skip to content

Instantly share code, notes, and snippets.

@cartpauj
cartpauj / mepr-disable-after-signup-reminder.php
Created January 4, 2019 00:03
Disable signup reminder in MemberPress if user has cancelled monthly membership, or has upgraded to annual membership already
<?php
// THIS CODE CAN BE PASTED INTO A PLUGIN LIKE Code Snippets, My Custom Functions, or placed in a Child Theme's functions.php file
// Begin copying from line #4 below
function disable_mepr_reminder_if_cancelled_or_upgraded($disable_email, $reminder, $usr, $prd) {
global $wpdb;
//BEGIN EDITING
$annual_membership_id = 2974;
$monthly_membership_id = 2973;
//STOP EDITING
@cartpauj
cartpauj / mepr-unprotect-by-category.php
Created January 18, 2019 19:05
Unprotect MemberPress posts if they have a certain category
<?php
// This code can be pasted into a plugin like Code Snippets or My Custom Functions or
// pasted into a child-theme's functions.php file
// You might have a Rule protecting all posts, but want posts with a certain category
// to be unprotected.
// You can do that with the code below.
// EDIT: You will need to edit the category_slug_here part is all.
@cartpauj
cartpauj / tracking_pixel_memberpress_footer.php
Last active February 20, 2019 20:50
Adds a tracking pixel with sale info in the wp_footer on MemberPress Thank You page
@cartpauj
cartpauj / memberpress-display-name.php
Created November 16, 2015 17:59
Adds display name settings to MemberPress
<?php
/*
Plugin Name: MemberPress Display Name
Plugin URI: https://memberpress.com
Description: Adds a Display Name field to MemberPress signup and account pages
Version: 1.0
Author: Caseproof, LLC
Author URI: http://caseproof.com/
Copyright: 2004-2014, Caseproof, LLC
*/
@cartpauj
cartpauj / mepr-nua-approve-by-email-domain.php
Last active June 18, 2019 18:11
Using the New User Approve Plugin + MemberPress to allow filtered domains through
<?php
/*
Plugin Name: MemberPress + New User Approve
Version: 1.0.0
Author: Caseproof, LLC
Author URI: http://caseproof.com
Description: Helps the flow of signups from approved/unapproved domains between the MemberPress and New User Approve plugins
*/
function mepr_get_approved_domains() {
@cartpauj
cartpauj / mepr-user-pro-profile-visibility.php
Last active June 21, 2019 17:23
UserPro hide or show profile based on subscription status
<?php
function mepr_sync_user_pro_visibility($txn, $status = false) {
global $userpro;
if(class_exists('MeprUser')) {
$user = new MeprUser($txn->user_id);
//Make sure it's a valid user still
if(!isset($user->ID) || !$user->ID) { return; }
@cartpauj
cartpauj / mepr-limit-signups-by-country.php
Last active July 16, 2019 14:00
Limit MemberPress Signups to one Country
<?php
function limit_signups_to_one_country($errors) {
// Limit Signups to USA only
if(!isset($_POST['mepr-address-country']) || $_POST['mepr-address-country'] != 'US') {
$errors[] = 'Sorry, signups are currently limited to USA only.';
}
return $errors;
}
add_filter('mepr-validate-signup', 'limit_signups_to_one_country');
@cartpauj
cartpauj / mepr-disable-lost-changed-pw.php
Created July 19, 2019 14:05
Disable Password Lost/Changed email to admins in MemberPress
<?php
// This disables the admin email notice of password resets in MemberPress.
// In some cases WordPress still sends its own out, there may be other plugins
// that will disable the WP one.
function disable_lost_and_changed_mepr($recipients, $subject, $message, $headers) {
if(strpos(strtolower($subject), 'password lost') !== false) {
$recipients = array();
}
return $recipients;
@cartpauj
cartpauj / mepr-account-info-shortcode-extension.php
Last active August 21, 2019 15:34
MemberPress Account Info Shortcode Extension - Specify User ID
<?php
// This code adds a new shortcode similar to MemberPress' [mepr-account-info]
// However, it also adds an "id" parameter which will get info for a specific user
// by their ID.
//
// Sample Usage: [mepr-account-info-extended field="slug" id="123"]
// field = The slug of your usermeta or custom field
// id = The WP User ID of the user you wish to pull information for
// List of available slugs here: https://docs.memberpress.com/article/112-available-shortcodes
//
@cartpauj
cartpauj / pretty-links-cpt-reset.sql
Created October 9, 2019 19:25
Pretty Links 3.0 reset CPT's Queries