Skip to content

Instantly share code, notes, and snippets.

Jason Coleman ideadude

Block or report user

Report or block ideadude

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ideadude
ideadude / my_add_meta_queries_to_pmpro_directory_search.php
Created Jan 17, 2020
Allow meta filtering of the PMPro membership directory
View my_add_meta_queries_to_pmpro_directory_search.php
/**
* Allow meta filtering of the membership directory
* if pk and ps params are passed into the URL.
* PMPro and the PMPro Member Directory Add Ons should be active.
* Then add this code to a custom plugin.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_add_meta_queries_to_pmpro_directory_search( $sql_parts ) {
global $wpdb;
@ideadude
ideadude / directory.php
Created Jan 17, 2020 — forked from greathmaster/directory.php
Custom directory template. Alphabetical last name search, and meta key/value search.
View directory.php
<?php
/*
Custom directory template. Adds alphabetical last name query. For example you can use the URL:
http://www.example.com/membership-account/directory/?lt=A
if you want all the members with last names starting with 'A'.
Also includes meta key/value search. For example you can use the URL:
@ideadude
ideadude / my_default_pmpro_discount_code.php
Last active Jan 7, 2020
Use a default discount code for the PMPro checkout page.
View my_default_pmpro_discount_code.php
<?php
/**
* Use a default discount code for the PMPro checkout page.
* Change the DEFAULT code to the one you want to use.
* You could alter this to check the $pmpro_level global to
* do this only for certain levels.
* You could add other logic to exclude existing customers/etc.
* Add this code to a custom plugin or Code Snippet.
*/
function my_default_pmpro_discount_code() {
@ideadude
ideadude / my_update_rh_fields.php
Last active Jan 22, 2020
Update PMPro Register Helper fields after they've been setup, e.g. to add them to the Add Member screen.
View my_update_rh_fields.php
/**
* Update RH fields after they've been setup.
* The example below sets the addmember property to true.
* Add this code to a custom plugin or Code Snippet.
*/
function my_update_rh_fields() {
global $pmprorh_registration_fields;
if ( empty( $pmprorh_registration_fields ) ) {
return;
@ideadude
ideadude / give_users_free_level_on_main_site.php
Created Dec 17, 2019
Give PMPro members on one subsite membership on another subsite.
View give_users_free_level_on_main_site.php
/**
* When a user is given a level, give add that user to another site
* in the network and give them a level there too.
* PMPro should be active on both blogs.
* The other blog should have the membership level already setup, note the ID.
* Blog/site IDs can be found in the Sites page of the network dashboard.
* This is not mean to work with the other PMPro multisite add ons.
* Add this to a custom plugin or as a Code Snippet on your site.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@ideadude
ideadude / my_pmpro_pages_custom_template_path.php
Last active Jan 7, 2020
Tell PMPro to look for templates in this plugin's templates/ folder.
View my_pmpro_pages_custom_template_path.php
<?php
/**
* Tell PMPro to look for templates in this plugin's templates/ folder.
*/
function my_pmpro_pages_custom_template_path( $templates, $page_name ) {
$templates[] = plugin_dir_path(__FILE__) . 'templates/' . $page_name . '.php';
return $templates;
}
add_filter( 'pmpro_pages_custom_template_path', 'my_pmpro_pages_custom_template_path', 10, 2 );
@ideadude
ideadude / pmpro_set_enddates.sql
Created Dec 2, 2019
Set an enddate for active subscriptions with PMPro
View pmpro_set_enddates.sql
# BACKUP FIRST
# This SQL query will set the expiration date
# to 2020-01-01 for any active membership with
# a different current enddate.
# BACKUP FIRST
UPDATE wp_pmpro_memberships_users
SET enddate = '2020-01-01 00:00:00'
WHERE status = 'active'
AND enddate IS NOT NULL
AND enddate <> '0000-00-00 00:00:00'
@ideadude
ideadude / my_init_membership_level_translate.php
Last active Dec 3, 2019 — forked from strangerstudios/my_init_membership_level_translate.php
Translate Membership Level Names and Descriptions with Paid Memberships Pro
View my_init_membership_level_translate.php
<?php
/*
* Filter membership level names and descriptions for translating.
*
* Add this code to a custom plugin or your active theme's functions.php file.
* Be sure to update the $pmpro_translated_levels array. Add a sub array for each locale.
* The sub array keys should be the membership level ids,
* and values should be an array with the name and description to translate to.
*
*/
@ideadude
ideadude / my_pmprodon_donation_notes.php
Created Nov 21, 2019
Donation notes field example for PMPro Donations.
View my_pmprodon_donation_notes.php
<?php
/**
* Donation notes.
* Edit the copy below.
* Add to a custom plugin.
* Notes are saved into the notes field of the order.
*/
// show the notes field at checkout.
function my_pmprodon_donation_notes() {
global $pmpro_level;
@ideadude
ideadude / pmpro_register_helper_depends_field_example.php
Created Oct 28, 2019
Example of one RH field depending on another.
View pmpro_register_helper_depends_field_example.php
<?php
// This code should be placed into context of adding RH fields
// like this: https://www.paidmembershipspro.com/documentation/register-helper-documentation/code-examples/
//define the fields
$fields = array();
$fields[] = new PMProRH_Field(
'budget', // input name, will also be used as meta key
'select', // type of field
array(
You can’t perform that action at this time.