Skip to content

Instantly share code, notes, and snippets.

@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_hide_level_from_levels_page.php
Last active April 8, 2021 18:21 — forked from greathmaster/pmpro-restrict-visibility-of-levels-on-levels-page.php
Limits the visibility of a level on the Levels page. Unlike setting "Allow Signups" members can access the checkout page to renew if needed.
<?php
//Save the pmpro_show_level_ID field
function pmpro_hide_level_from_levels_page_save( $level_id ) {
if( $level_id <= 0 ) {
return;
}
$limit = $_REQUEST['pmpro_show_level'];
update_option( 'pmpro_show_level_'.$level_id, $limit );
}
add_action( 'pmpro_save_membership_level','pmpro_hide_level_from_levels_page_save' );
@strangerstudios
strangerstudios / my_pmpro_dashboard_report.php
Last active April 14, 2022 03:37 — forked from andrewlimaza/my_custom_dashboards.php
Show Membership Reports on the WordPress Admin Dashboard
<?php
/*
Show Members Reports on the WordPress Admin Dashboard.
Update the my_pmpro_dashboard_report() function to remove or add core or custom reports.
*/
//Create a Dashboard Reports widget for Paid Memberships Pro
function add_my_report_dashboard() {
if( ! defined( 'PMPRO_DIR' ) || ! current_user_can( 'manage_options' ) )
{
<?php
//Address merge types must be handled in a very specific format
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user)
{
$user_info = get_userdata($user->ID);
$new_fields = array(
"FNAME" => $user->first_name,
"EMAIL" => $user->email,
"LNAME" => $user->last_name,
@strangerstudios
strangerstudios / howibuit.md
Created August 5, 2016 18:04 — forked from jcasabona/howibuit.md
Guest Notes for How I Built It Podcast

Guest Notes for How I Built It Podcast

Format

We will pick a product you developed to talk about and I will ask 6 questions about it. The target is a 20-30 minute show that's pretty focused.

I will open the show, mention the show's sponsor(s) and then introduce you. We'll then jump into the questions.

Questions

@strangerstudios
strangerstudios / pmpro-apply-addon-access-to-all-child-pages.php
Last active April 13, 2021 04:30 — forked from eighty20results/pmpro-apply-addon-access-to-all-child-pages.php
Protect all child pages of a page protected by the "Protect Add-on Pages" add-on
<?php
/*
Plugin Name: Paid Memberships Pro - Protect Child Pages Add On
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Apply protection to all child pages of a Add-on Page that's protected.
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: https://eighty20results.com/thomas-sjolshagen/
*/
/**
@strangerstudios
strangerstudios / pmpro-restrict-countries.php
Created May 10, 2016 11:28 — forked from greathmaster/pmpro-restrict-countries.php
Restrict certain countries from signing up for certain levels.
function my_init()
{
global $restricted_countries;
//specify the countries not allowed to signup. The key is the level id.
$restricted_countries = array(
1 => array('FR', 'IT'),
2 => array('IT'),
);
}
<?php
/*
Plugin Name: Register Helper Example
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Register Helper Initialization Example
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
<?php
/*
Plugin Name: Register Helper Example
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Register Helper Initialization Example
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
@strangerstudios
strangerstudios / my_pmpro_email_body.php
Last active April 16, 2021 23:20 — forked from scottsousa/gist:6700307
This code recipe adds the level’s Confirmation Message (under Memberships > Levels > Edit Level) to the membership checkout e-mail.
/**
* This function allows a custom confirmation message to be added to a checkout e-mail template. This will allow you to add
* your custom confirmation message to an e-mail template, without creating your own custom template in your theme.
*
* We're checking for the "checkout_" prefix on the e-mail template name and if we have current user data.
* We're then getting the custom confirmation level based on the current user data.
* We replace the 'is now active.</p>' portion of the body to append the confirmation message.
*/
add_filter( 'pmpro_email_body', 'my_pmpro_email_body', 10, 2 );
function my_pmpro_email_body( $body, $email ) {