Skip to content

Instantly share code, notes, and snippets.

<?php
/*
This is the main template part used in the tabbed search results as they are found at www.paidmembershipspro.com.
This will not function on it's own. Some notes:
* This is part of a child theme using the Memberlite theme as a parent.
* There is a search.php file in the child theme folder that loads this template part.
* There is also a search-result.php template part used by this.
* This also relies on CSS styles in Memberlite and our child theme.
*/
@strangerstudios
strangerstudios / inc_extras_patch.php
Last active August 26, 2015 15:15
Memberlite 2.0.3 XSS Patch
//line 305 of inc/extras.php
//change:
elseif(is_search())
{
?>
<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'memberlite' ), '<span>' . esc_attr(get_search_query()) . '</span>' ); ?></h1>
<?php
}
.wp-social-login-connect-with {float: left; margin-right: 1em !important; }
.wp-social-login-provider-list {clear: none !important; padding: 0; }
.wp-social-login-provider-list a {border: none; display: inline-block; text-decoration: none; }
@strangerstudios
strangerstudios / my_pmpro_constant_contact_custom_fields.php
Created February 7, 2014 22:17
Add a custom field to user data using pmpro-constant-contact.
//filter constant contact fields
function my_pmpro_constant_contact_custom_fields($fields, $user)
{
$fields[] = array("name"=>"CustomField1", "value"=>$user->user_login);
return $fields;
}
add_filter("pmpro_constant_contact_custom_fields", "my_pmpro_constant_contact_custom_fields", 10, 2);
@strangerstudios
strangerstudios / custom_pmpro_getMemberStartdate.php
Last active August 29, 2015 13:56
Filter the pmpro_getMemberStartdate() function in Paid Memberships Pro. (Requires PMPro v1.7.8 or higher)
function custom_pmpro_getMemberStartdate($timestamp, $user_id, $level_id)
{
global $wpdb;
if(!empty($level_id))
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE membership_id IN(" . esc_sql($level_id) . ") AND user_id = '" . esc_sql($user_id) . "' ORDER BY id LIMIT 1";
else
$sqlQuery = "SELECT UNIX_TIMESTAMP(startdate) FROM $wpdb->pmpro_memberships_users WHERE user_id = '" . esc_sql($user_id) . "' ORDER BY id LIMIT 1";
$timestamp = $wpdb->get_var($sqlQuery);
@strangerstudios
strangerstudios / pmpro_xmlrpc_test.php
Last active August 29, 2015 13:56
Test code for the XMLRPC methods added to Paid Memberships Pro in PMPro v2.0. Add this to your active theme's functions.php or a custom plugin, then navigate to /?rpctest=1.
/*
This code is just meant as a sample of how to use the new XMLRPC methods in PMPro.
Aftering adding this code, navigate to /?rpctest=1
*/
function xmlrpc_test()
{
if(!empty($_REQUEST['rpctest']) && current_user_can("manage_options"))
{
//load XMLRPC Client
include(ABSPATH . "/wp-includes/class-IXR.php");
mysqldump -uusername -ppassword dbname > dbname_`date +'%Y-%m-%d'`.sql
gzip dbname_`date +'%Y-%m-%d'`.sql
@strangerstudios
strangerstudios / my_pmpro_after_checkout_tos_save.php
Last active August 29, 2015 13:56
Save the date the TOS was checked at checkout with Paid Memberships Pro
//add field to profile
function my_pmprorh_init()
{
if(!function_exists("pmprorh_add_registration_field"))
return;
$secret = new PMProRH_Field("tos_checked_date", "readonly", array("profile"=>"admin", "label"=>"TOS Checked Date"));
pmprorh_add_registration_field("checkout_boxes", $secret);
}
@strangerstudios
strangerstudios / my_pmpro_profile_start_date.php
Created March 18, 2014 17:44
Add 2 week trial to a monthly subscription plan
//change the profile start date
function my_pmpro_profile_start_date($date, $order)
{
if($order->membership_id == 1)
$date = date("Y-m-d", strtotime("+ 14 Days")) . "T0:0:0";
return $date;
}
add_filter("pmpro_profile_start_date", "my_pmpro_profile_start_date", 10, 2);
@strangerstudios
strangerstudios / my_pmpro_has_membership_access_filter.php
Created March 31, 2014 15:25
Make a single post explicitly public with Paid Memberships Pro.
<?php
function my_pmpro_has_membership_access_filter($access, $post, $user)
{
if($post->ID == "1") //change ID here
return true;
return $access;
}
add_filter('pmpro_has_membership_access_filter', 'my_pmpro_has_membership_access_filter', 10, 3);