Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / pmprorh_add_checkout_box.php
Created April 4, 2016 21:57
pmprorh_add_checkout_box() example
pmprorh_add_checkout_box("personal", "Personal Information"); //order parameter defaults to one more than the last checkout box
pmprorh_add_checkout_box("business", "Business Information", "Fields below are optional but will help us in verifying your account.");
@strangerstudios
strangerstudios / pmprorh_add_registration_field.php
Created April 4, 2016 21:56
Example of pmprorh_add_registration_field function.
$field = new PMProRH_Field("gender", "select", array("options"=>array("" => "", "male"=>"Male", "female"=>"Female")));
pmprorh_add_registration_field("personal", $field);
$field = PMProRH_Field("company", "text", array("size"=>40, "class"=>"company", "profile"=>true, "required"=>true));
pmprorh_add_registration_field("business", $field);
@strangerstudios
strangerstudios / pmpro_expiration_date_shortcode.php
Last active October 31, 2023 06:40
Shortcode to show a member's expiration date with Paid Memberships Pro
/*
Shortcode to show a member's expiration date.
Add this code to your active theme's functions.php or a custom plugin.
Then add the shortcode [pmpro_expiration_date] where you want the current user's
expiration date to appear.
If the user is logged out or doesn't have an expiration date, then --- is shown.
*/
@strangerstudios
strangerstudios / my_pmpro_filter_wpseo_metadesc.php
Last active April 13, 2021 17:58
Filter the Membership Checkout meta description using Yoast SEO.
<?php
//Update line 6 below to your preferred dynamic page description.
function my_pmpro_filter_wpseo_metadesc($description) {
global $pmpro_pages, $pmpro_level;
if( is_page($pmpro_pages['checkout']) ) {
$description = $pmpro_level->description;
}
return $description;
}
add_filter('wpseo_metadesc', 'my_pmpro_filter_wpseo_metadesc');
@strangerstudios
strangerstudios / my_pmpro_filter_wpseo_title.php
Last active April 13, 2021 17:57
Filter the Membership Checkout wp_title using Yoast SEO.
<?php
//Update line 6 below to your preferred dynamic page title
function my_pmpro_filter_wpseo_title($title) {
global $pmpro_pages, $pmpro_level;
if( is_page($pmpro_pages['checkout']) ) {
$title = $pmpro_level->name . ': Complete Your Membership Checkout';
}
return $title;
}
add_filter('wpseo_title', 'my_pmpro_filter_wpseo_title');
@strangerstudios
strangerstudios / pmpro_auto_renew_box.php
Last active March 21, 2018 14:54
Add a box to choose to auto renew at checkout with PMPro.
<?php
/*
*************** !!
!! IMPORTANT NOTE: This can more easily be done using the addon maintained here:
!! https://github.com/strangerstudios/pmpro-auto-renewal-checkbox
*************** !!
Allow users to choose to auto renew
1. Edit the global variable below to set the renewal amount (can be the same or less) for each level.
2. Paste this code into your active theme's functions.php or a custom plugin.
@strangerstudios
strangerstudios / addon-package-fields.php
Last active March 21, 2018 14:54
Example of how to show a field at checkout for addon packages only.
<?php
/*
This field is for addon packages only.
*/
if(!empty($_REQUEST['ap'])) //might want to also look up ap to see if it's active/etc
$profile = true;
else
$profile = 'only_admin';
$fields[] = new PMProRH_Field(
@strangerstudios
strangerstudios / custom_addon_package_prices.php
Created March 22, 2016 18:55
Charge different prices for different membership levels with PMPro and PMPro Addon Packages.
/*
Charge different prices for different membership levels.
*/
//global var to store the price configurations
global $custom_addon_package_prices;
$custom_addon_package_prices = array(
//post_id => array(level_id => price, level_id => price, ...)
353 => array(1 => 1500, 2 => 1000, 3 => 500)
);
@strangerstudios
strangerstudios / my_pmprorh_depends_fields_init.php
Last active April 13, 2021 18:10
Demonstration of the Register Helper "depends" field option.
<?php
function my_pmprorh_depends_fields_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
//add a new "About Your Pets" box on checkout form
@strangerstudios
strangerstudios / pmpro_shortcodes_later.php
Created March 9, 2016 17:38
Run PMPro shortcodes later to avoid issues with the_content filters/etc
/*
Run PMPro shortcodes later to avoid issues with the_content filters/etc
Add this code to your active theme's functions.php or a custom plugin.
You may need to change the priority of the add_filter calls below to get the desired result.
*/
//this function removes the shortcodes to keep them from being messed with
function pmpro_shortcodes_later_prep($content) {
$shortcodes = array('pmpro_account', 'pmpro_billing', 'pmpro_cancel', 'pmpro_checkout', 'pmpro_confirmation', 'pmpro_invoice', 'pmpro_levels');