Skip to content

Instantly share code, notes, and snippets.

@messica
messica / my_pmpro_login_redirect_url.php
Created June 26, 2014 15:44
Redirect admins to dashboard, everyone else to home page.
<?php
/*
* Redirect admins to dashboard, everyone else to home page.
*/
function my_pmpro_login_redirect_url($url, $request, $user) {
//only do this if we have a user
if(is_a($user, 'WP_User')) {
if(in_array('administrator', $user->roles))
<?php
/*
Plugin Name: PMPro Address For Free Levels
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-address-for-free-levels/
Description: Show address fields for free levels also with Paid Memberships Pro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@messica
messica / my_pmpro_registration_checks.php
Created October 2, 2014 14:51
Limit number of checkouts for a specific membership level
<?php
/*
* Limit checkouts for membership level
*/
function my_pmpro_registration_checks($continue_registration) {
global $wpdb;
@messica
messica / getDaysUntilExpiration.php
Created December 22, 2014 17:35
PMPro - get the number of days until expiration
<?php
/*
* Return the # of days until expiration for a given user
*/
function getDaysUntilExpiration($user_id = NULL) {
global $current_user;
if(!$user_id)
<?php
/*
Plugin Name: PMPro Custom Import
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Custom Import Code for PMPro
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
@messica
messica / pmpro-customizations.php
Created March 18, 2015 15:25
Show Billing Address Fields in Profile
<?php
/*
* Add PMPro Billing Fields to Profile
*/
function my_show_extra_profile_fields($user)
{
global $pmpro_states;
?>
/*
Show payment options (as levels) at checkout.
*/
// Define groups of levels. array(1,2) means that levels 1 and 2 are in a group and options will be shown for both levels at checkout for those levels.
global $pmpro_level_groups;
$pmpro_level_groups = array(array(1,2));
//show options at checkout
function pmprogl_pmpro_checkout_boxes()
@messica
messica / my_init.php
Created October 20, 2015 15:58
Generate invite codes for all users with a certain membership level.
<?php
/*
* Generate invite codes for all users with a certain membership level.
*/
function my_init() {
if ( ! empty( $_REQUEST['create_invites'] ) && current_user_can( 'manage_options' ) ) {
global $wpdb;
@messica
messica / pmpro_copy_membership_requirements.php
Last active August 4, 2016 19:59
Copy membership post requirements from one level to another.
<?php
/*
* Copy Membership Requirements from one level to another
*
* Instructions:
* 1. Set $copy_from and $copy_to to the level IDs you want
* 2. Visit any page of your site and add "&copy_membership=1" to the address.
*
*/
function pmpro_copy_membership_requirements() {
@messica
messica / pmpro_cancel_on_next_payments_date.php
Created March 30, 2017 20:58 — forked from strangerstudios/pmpro_cancel_on_next_payments_date.php
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id) {
//are we on the cancel page?