Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / pmpro-fields.php
Created August 31, 2014 23:22
Custom Fields for PMPro (Church Site)
<?php
/*
Plugin Name: PMPro Fields
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-fields/
Description: Register Helper Initialization Example
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
/*
@strangerstudios
strangerstudios / my_pmpro_checkout_level_extend_memberships.php
Last active February 21, 2025 16:56
By default PMPro will only "extend" a membership level if you checkout for the same level. This code will make it so PMPro extends any expiring level with any new expiring level. E.g. if you change from a annual plan to a monthly plan it will add 30 days to the end of your existing membership.
<?php
/*
If checking out for ANY level with an expiration, add remaining days to the enddate.
Pulled in from: https://gist.github.com/3678054
*/
function my_pmpro_checkout_level_extend_memberships($level)
{
global $pmpro_msg, $pmpro_msgt, $current_user;
//does this level expire? are they an existing members with an expiration date?
@strangerstudios
strangerstudios / my_init_pmpro_payment_options.php
Created November 22, 2014 19:23
Get PMPro Pay By Check and PMPro Add PayPal Express to work together.
/*
Get PMPro Pay By Check and PMPro Add PayPal Express to work together.
*/
//remove the checkout_boxes code from both plugins
function my_init_pmpro_payment_options()
{
remove_action("pmpro_checkout_boxes", "pmpropbc_checkout_boxes");
remove_action("pmpro_checkout_boxes", "pmproappe_pmpro_checkout_boxes", 20);
add_action("pmpro_checkout_boxes", "my_pmpro_checkout_boxes_payment_options");
@strangerstudios
strangerstudios / my_pmpro_paypal_button_image.php
Last active February 10, 2025 16:36
Using the pmpro_paypal_button_image filter to change the PayPal button image on the PMPro checkout page.
/*
Add this code to your active theme's functions.php or a custom plugin
to change the PayPal button image on the PMPro checkout page.
*/
function my_pmpro_paypal_button_image($url)
{
return "https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-large.png";
}
add_filter('pmpro_paypal_button_image', 'my_pmpro_paypal_button_image');
@strangerstudios
strangerstudios / my_pmpro_confirmation_url.php
Created April 8, 2016 14:47
Example of using the pmpro_confirmation_url filter to change the PMPro confirmation page for new users.
function my_pmpro_confirmation_url($url, $user_id, $level) {
$already_member = get_user_meta($user_id, 'already_member', true);
if(!$already_member) {
update_user_meta($user_id, 'already_member', 1);
$url = home_url('/my-dashboard');
}
return $url;
}
add_filter('pmpro_confirmation_url', 'my_pmpro_confirmation_url');
@strangerstudios
strangerstudios / gist:5573829
Last active January 10, 2025 12:48
Paid Memberships Pro customization to only let members of a certain level checkout if a discount code was used.
/*
Only let level 1 members sign up if they use a discount code.
Place this code in your active theme's functions.php or a custom plugin.
*/
function my_pmpro_registration_checks_require_code_to_register($pmpro_continue_registration)
{
//only bother if things are okay so far
if(!$pmpro_continue_registration)
return $pmpro_continue_registration;
@strangerstudios
strangerstudios / my_pmpro_members_list_csv_extra_columns.php
Last active December 19, 2024 09:06
Add a custom field to the members list CSV export in Paid Memberships Pro.
<?php
/*
Add employer, title, and department columns to the members list CSV export.
Just add this code to your functions.php or a custom plugin.
The first function here defines the column headers and a callback function for each column.
*/
function my_pmpro_members_list_csv_extra_columns($columns)
{
$columns["employer"] = "my_extra_column_employer";
@strangerstudios
strangerstudios / my_pmpro_additional_categories.php
Last active December 19, 2024 06:00
Add "Purchase Additional Access" box to Membership Checkout for a la carte category purchase.
/*
Require specific category user meta to view posts in designated categories.
Custom price-adjusting fields are added via PMPro Register Helper add on (required).
Add all of this code to your active theme's functions.php or a custom plugin.
*/
add_filter("pmpro_has_membership_access_filter", "my_pmpro_additional_categories", 10, 4);
function my_pmpro_additional_categories($hasaccess, $thepost, $theuser, $post_membership_levels)
{
global $wpdb;
@strangerstudios
strangerstudios / my_user_page_template_redirect.php
Created May 29, 2015 17:43
Redirect from /my-user-page/ to a user's user page using pmpro-user-pages.
*
Create a page with the slug /my-user-page/,
or if something different be sure to change the code below.
You can then link to /my-user-page/ or add that as a link to your menu
that will redirect to a user's user page.
Redirect /my-user-page/ to a user's user page
or checkout if they do not have one.
*/
@strangerstudios
strangerstudios / lockdown_menus_and_recipes.sql
Created August 25, 2015 16:18
require level 2 on all posts of type recipe or menu
#require level 2 on all posts of type recipe or menu
INSERT INTO wp_pmpro_memberships_pages (membership_id, page_id)
SELECT 2, page_id FROM wp_posts WHERE post_type IN('menus', 'recipes') AND post_status = 'publish'