Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / set_enddate_null.sql
Created April 5, 2017 14:30
This SQL query will clear the expiration date for active recurring memberships in Paid Memberships Pro.
# BACKUP FIRST
# You generally do not want to setup PMPro levels
# with both a recurring billing amount AND
# an expiration date.
# This SQL query will clear the expiration date
# for active recurring memberships.
# BACKUP FIRST
UPDATE wp_pmpro_memberships_users
SET enddate = '0000-00-00 00:00:00'
WHERE status = 'active'
@strangerstudios
strangerstudios / requires_membership_pages_columns.php
Last active April 12, 2021 22:34
Add a "Requires Membership" column to the All Pages dashboard page to show what levels are required to view. Raw
<?php
//add a new column to the all pages view
function requires_membership_pages_columns_head( $defaults ) {
$defaults['requires_membership'] = 'Requires Membership';
return $defaults;
}
//get the column data
function requires_membership_pages_columns_content( $column_name, $post_ID ) {
if ($column_name == 'requires_membership') {
global $membership_levels, $wpdb;
@strangerstudios
strangerstudios / requires_membership_posts_columns.php
Created March 30, 2017 15:52
Add a "Requires Membership" column to the All Posts dashboard page to show what levels are required to view.
<?php
//add a new column to the all posts view
function requires_membership_posts_columns_head( $defaults ) {
$defaults['requires_membership'] = 'Requires Membership';
return $defaults;
}
//get the column data
function requires_membership_posts_columns_content( $column_name, $post_ID ) {
if ($column_name == 'requires_membership') {
global $membership_levels, $wpdb;
@strangerstudios
strangerstudios / requires_membership_categories_columns.php
Created March 30, 2017 15:51
Add a "Requires Membership" column to the Categories dashboard page to show what levels are required to view.
<?php
//add a new column to the categories view
function requires_membership_categories_columns_head( $defaults ) {
$defaults['requires_membership'] = 'Requires Membership';
return $defaults;
}
//get the column data
function requires_membership_categories_columns_content( $content, $column_name, $term_id ) {
if ($column_name == 'requires_membership') {
@strangerstudios
strangerstudios / pmpro_reports_changes.php
Last active April 7, 2021 02:41
A report to show membership level changes (upgrades or downgrades) from initial level to current level.
<?php
/*
Changes Report for Paid Memberships Pro
Title: pmpro_reports_changes
Slug: pmpro_reports_changes
*/
//update this array for your desired reports. the format is: "report name" => array( initial_level_id, current_level_id ),
global $pmpro_reports_level_changes;
$pmpro_reports_level_changes = array(
@strangerstudios
strangerstudios / my_pmpro_members_list_csv_extra_columns.php
Last active April 12, 2021 22:35
Add columns to the Members List CSV Export.
<?php
/*
Add data from the wp_users, wp_user_meta, or BuddyPress xProfile fields tables to the Members List CSV Export.
The pmpro_members_list_csv_extra_columns passes an array of columns.
The keys of the array are the column headings. The values are callback functions to get the value for that row.
*/
//add the column to the export
function my_pmpro_members_list_csv_extra_columns ( $columns ) {
@strangerstudios
strangerstudios / open_new_posts_to_non_members.php
Created March 22, 2017 14:36
PMPro Customizations to allow non-members to view restricted posts if they are less than 30 days old.
/*
Allow non-members to view restricted posts if they are less than 30 days old.
Add this code to a custom plugin.
Change the '-30 Days' below if you'd like to allow access for longer or shorter.
*/
function open_new_posts_to_non_members($hasaccess, $thepost, $theuser, $post_membership_levels)
{
global $wpdb;
@strangerstudios
strangerstudios / pmpro-limit-members-per-level.php
Last active April 16, 2024 09:29 — forked from greathmaster/pmpro-limit-members-per-level.php
Limit the number of total sign ups for a given membership level
<?php
/*
Set a maximum number of members allowed to register for a membership level.
Add this code to a plugin for PMPro Customizations.
Set the "Maximum" for a level on the Memberships > Membership Levels > Edit Level admin page.
*/
function pmproml_pmpro_save_membership_level( $level_id) {
if( $level_id <= 0 ) {
@strangerstudios
strangerstudios / pmpro_ld2aff.php
Created March 20, 2017 18:43
Link Paid Memberships Pro discount codes to affiliate accounts from another plugin/service.
/*
Link discount codes to affiliates.
*/
//this is the parameter we're looking for to find affiliates... based on which plugin/etc you are using
define('PMPRO_LDC2AFF_KEY', 'wpam_id'); //Affiliates Manager Plugin
//define('PMPRO_LDC2AFF_KEY', 'pa'); //WordPress Lightweight Affiliates
//define('PMPRO_LDC2AFF_KEY', 'ref'); //AffiliateWP
//helper function to get the values from options and make sure they are an array
function pmpro_ld2aff_getOptions() {
@strangerstudios
strangerstudios / pmpro-australia-gst.php
Created March 15, 2017 20:35
Paid Memberships Pro - Australia GST
<?php
/*
Plugin Name: Paid Memberships Pro - Australia GST
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-australia-gst/
Description: Apply Australia GST to Checkouts with PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*