Skip to content

Instantly share code, notes, and snippets.

View eighty20results's full-sized avatar

Thomas Sjølshagen eighty20results

View GitHub Profile
@eighty20results
eighty20results / preserve-startdate-including-registration-date.php
Last active April 16, 2018 19:37
Preserve startdate on membership level change
/*
Keep members start dates at checkout, even if switching levels.
*/
function custom_pmpro_checkout_start_date($date, $user_id, $level)
{
global $wpdb;
// Comment this out if you want to use the users registration date (Warning: Registration date may not contain data...)
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . esc_sql($user_id) . "' ORDER BY id LIMIT 1";
<?php
/*
Plugin Name: PMPro Directory Customization
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Show all PMPro Users in directory (regardless of status).
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: http://www.strangerstudios.com
*/
@eighty20results
eighty20results / pmpro-billing-info-in-profile.php
Last active February 16, 2016 14:35
Add billing info to the users profile
<?php
/*
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins.
*/
function my_show_pmpro_address_fields_in_profile()
{
//require PMPro and PMPro Register Helper
if(!defined('PMPRO_VERSION') || !defined('PMPRORH_VERSION'))
return;
@eighty20results
eighty20results / pmpro-rh-for-legacy-brands.php
Created February 16, 2016 15:47
Register Helper fields that also use the default WordPress meta field names for "First name" and "Last name".
<?php
function my_add_pmpro_RH_fields()
{
//require PMPro and PMPro Register Helper
if (!defined('PMPRO_VERSION') || !defined('PMPRORH_VERSION'))
return;
$fields = array();
$fields[] = new PMProRH_Field(
"first_name", // Input name, will also be used as the key to access as user meta
@eighty20results
eighty20results / pmpro-rh-for-legacy-brands.php
Created February 16, 2016 15:54
Register Helper fields that also use the default WordPress meta field names for "First name" and "Last name".
<?php
/*
Plugin Name: Additional Checkout Fields (PMPro Register Helper)
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Additional Checkout page & profile fields for the Paid Memberships Pro Register Helper add-on
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: http://www.strangerstudios.com
*/
function my_add_pmpro_RH_fields()
@eighty20results
eighty20results / pmpro-rh-fields-for-femworking.php
Created February 16, 2016 17:34
Custom fields for Register Helper
<?php
/*
Plugin Name: Additional Checkout Fields (PMPro Register Helper)
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Additional Checkout page & profile fields for the Paid Memberships Pro Register Helper add-on
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: http://www.strangerstudios.com
*/
function my_add_pmpro_RH_fields()
@eighty20results
eighty20results / pmpro-birthday-validation.php
Last active March 9, 2016 22:36
Collect birthdate on checkout
<?php
/*
Add birthday to user signup and check that user is between 13-17.
Will not work with PayPal Standard or PayPal Express.
*/
//birthday fields
function my_pmpro_checkout_after_user_fields()
{
$current_day = date("j");
@eighty20results
eighty20results / pmpro-check-for-invalid-fqdn-in-email.php
Created February 29, 2016 12:57
Check for FQDNs that are supposed to trigger an "invalid email domain" error on checkout
<?php
function restrict_email($value)
{
$email = $_REQUEST['bemail'];
if(is_invalid($email))
{
global $pmpro_msg, $pmpro_msgt;
//TODO: Set the error text to be whatever you want it to be:
@eighty20results
eighty20results / functions.php
Created February 29, 2016 17:51
Proposal: pmpro_loadTemplate() function
function pmpro_loadTemplate($page_name = null, $type = 'pages', $ext = 'php' )
{
// called from page handler shortcode
if (is_null($page_name))
{
global $pmpro_page_name;
$page_name = $pmpro_page_name;
}
// template paths in order of priority (array gets reversed)
@eighty20results
eighty20results / hide-membership-levels.php
Created March 2, 2016 00:13
Hide all levels except the current user's membership level from the list of membership levels on display
<?php
/*
* Hide some levels from Levels page
*/
function my_pmpro_levels_array($levels) {
global $current_user;
// if the user is logged in
if (!empty($current_user->ID))