This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If we 404, and the slug matches a discount code, redirect | |
Add this code to a custom plugin | |
*/ | |
function my_pmpro_pre_handle_404($preempt, $wp_query) { | |
global $wpdb; | |
//make sure we're 404ing | |
if(!is_404()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Tell PMPro to look in the pages directory of this plugin for PMPro email templates. | |
Add this code to a custom plugin. | |
Make sure that there is a /email/ directory in the plugin directory with your templates in it. | |
*/ | |
function my_pmpro_email_custom_template_path($default_templates, $page_name) { | |
$default_templates[] = dirname(__FILE__) . '/email/' . $page_name . '.html'; | |
return $default_templates; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Save this file to /themes/{active theme}/paid-memberships-pro/member-directory/tempaltes/directory.php | |
*/ | |
/* | |
This shortcode will display the members list and additional content based on the defined attributes. | |
*/ | |
function pmpromd_shortcode($atts, $content=null, $code="") | |
{ | |
// $atts ::= array of attributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Link discount codes to affiliates. | |
*/ | |
//this is the parameter we're looking for to find affiliates... based on which plugin/etc you are using | |
define('PMPRO_LDC2AFF_KEY', 'wpam_id'); //Affiliates Manager Plugin | |
//define('PMPRO_LDC2AFF_KEY', 'pa'); //WordPress Lightweight Affiliates | |
//define('PMPRO_LDC2AFF_KEY', 'ref'); //AffiliateWP | |
//helper function to get the values from options and make sure they are an array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use PMPro Register Helper to add PMPro Billing Address fields to the edit user page for admins. | |
*/ | |
function show_pmpro_address_fields_on_edit_profile() | |
{ | |
//require PMPro and PMPro Register Helper | |
if(!defined('PMPRO_VERSION') || !defined('PMPRORH_VERSION')) | |
return; | |
$address_fields = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Example Register Helper fields for Company, Referral Code, and Budget. | |
* | |
*/ | |
// We have to put everything in a function called on init, so we are sure Register Helper is loaded. | |
function my_pmprorh_init() { | |
// Don't break if Register Helper is not loaded. | |
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
This code handles loading a file from the /protected-directory/ directory. | |
(!) Be sure to change line 19 below to point to your protected directory if something other than /protected/ | |
(!) Be sure to change line 66 below to the level ID or array of level IDs to check for the levels you need. | |
(!) Add this code to your active theme's functions.php or a custom plugin. | |
(!) You should have a corresponding bit of code in your Apache .htaccess file to redirect files to this script. e.g. | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Tell PMPro to look in the pages directory of this plugin for PMPro page templates. | |
Add this code to a custom plugin. | |
Make sure that there is a /pages/ directory in the plugin directory with your templates in it. | |
*/ | |
function my_pmpro_pages_custom_template_path( $default_templates, $page_name, $type, $where, $ext ) { | |
$default_templates[] = dirname(__FILE__) . '/pages/' . $page_name . '.' . $ext; | |
return $default_templates; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
[my_pmpro_addon] shortcode. | |
*/ | |
function my_pmpro_addon_shortcode() { | |
//load template | |
$content = pmpro_loadTemplate( 'my_pmpro_addon' ); //will look for /wp-content/themes/your-theme/paid-memberships-pro/pages/my_pmpro_addon.php | |
//maybe tweak the content a bit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the PMPro meta box to a CPT | |
*/ | |
function my_add_pmpro_meta_box_to_cpts() { | |
// Duplicate this row for each CPT. This one adds the meta boxes to 'product' CPTs. | |
add_meta_box('pmpro_page_meta', 'Require Membership', 'pmpro_page_meta', 'product', 'side' ); | |
} | |
add_action( 'admin_menu', 'my_add_pmpro_meta_box_to_cpts', 20 ); |
OlderNewer