Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / pmpro_hide_account_page_until_validated.php
Last active July 21, 2023 15:56
Hide the PMPro Account page until a user confirms their email address via the PMPro Email Confirmation addon.
/*
Add this function to a custom plugin.
Update your membership confirmation text then to include a reminder about confirming your email.
*/
function pmpro_hide_account_page_until_validated() {
//bail if pmpro or the email confirmation addon is not loaded
if(!function_exists('pmpro_getMembershipLevelForUser') || !function_exists('pmproec_isEmailConfirmationLevel'))
return;
@andrewlimaza
andrewlimaza / send_custom_email.php
Last active February 2, 2023 13:06
Send a custom email when a user checks out for a pmpro level.
<?php
/**
* Add this code to your PMPro Customizations Plugin - http://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* This function below sends a custom HTML email to the user that checks out for a pmpro membership level, easily extendible to send to admins, or specific users and so on.
* Website: https://paidmembershipspro.com
*/
//let's send a custom email after user checkouts. This will not send an email if an admin changes user's level inside member area.
function custom_email_after_checkout( $user_id, $morder ){
@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 November 11, 2024 16:02
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 / 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_levels_array.php
Created February 17, 2017 15:02
Use pmpro_levels_array filter to hide specific (in this level ID 1) levels.
function my_pmpro_levels_array($levels)
{
//a comma-separated list of the levels to hide
$hiddenlevels = array(1);
//build the filtered levels array
$newlevels = array();
foreach($levels as $key => $level) {
if( !in_array( $level->id, $hiddenlevels ) ) {
$newlevels[$key] = $level;
@strangerstudios
strangerstudios / enqueue_scripts_slowdown_checkout.php
Created February 13, 2017 14:39
Add a .5s delay every time the checkout PMPro checkout button is clicked.
/*
Add a .5s delay every time the checkout PMPro checkout button is clicked.
This is meant to prevent automated scripts from testing your checkout page repeatedly.
We will likely update this script to keep track on the server side as well to account for cases
where the script reloads the entire page with every attempt.
*/
function enqueue_scripts_slowdown_checkout() {
?>
<script>
function my_disablePMProCheckoutButtons() {
@strangerstudios
strangerstudios / my_default_wp_user_checkout_fields.php
Last active February 18, 2020 13:45
Capture default user profile fields at Membership Checkout using Register Helper
/*
Add Website and Biographical Info to Membership Checkout
*/
function my_default_wp_user_checkout_fields()
{
if(class_exists("PMProRH_Field"))
{
pmprorh_add_checkout_box("additional", "Additional Information");
$fields = array();
@strangerstudios
strangerstudios / hide_discount_code_field_for_specific_levels.php
Last active July 21, 2021 06:55
Hide discount code field on the PMPro checkout page for specified levels.
function hide_discount_code_field_for_specific_levels($show)
{
global $pmpro_level;
if( in_array( $pmpro_level->id, array(1,2) ) )
{
$show = false;
}
return $show;
}
@strangerstudios
strangerstudios / insert_members.sql
Last active April 13, 2021 03:06
SQL query to give all non-member WP users level 1 with a specific start and end date set.
#give all non-member WP users level 1 with a specific start and end date set
#change the level (1) below and start (2017-01-01) and end (2017-12-31) dates below to per your needs
INSERT INTO wp_pmpro_memberships_users (user_id, membership_id, status, startdate, enddate)
SELECT
u.ID, #ID from wp_users table
1, #id of the level to give users
'active', #status to give users
'2017-01-01', #start date in YYYY-MM-DD format
'2017-12-31' #end date in YYYY-MM-DD format, use '' for auto-recurring/no end date
FROM wp_users u