This file contains hidden or 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 hidden or 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
/** | |
* Add this code into a custom plugin. | |
* You could also add a direct call to session_start() in your wp-config.php | |
* or another piece of code that runs early. | |
*/ | |
add_action('plugins_loaded', 'pmpro_start_session'); |
This file contains hidden or 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
/** | |
* Autocomplete orders with only virtual products. | |
* From the 2nd edition of Building Web Apps with WordPress | |
* https://bwawwp.org | |
*/ | |
function autocomplete_virtual_orders($order_id) { | |
//get the existing order | |
$order = new WC_Order($order_id); | |
//assume we will autocomplete |
This file contains hidden or 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 | |
/** | |
* Functions affecting admins and the admin dashboard. | |
*/ | |
/** | |
* Return array of fields found in the wp_users table. | |
* This function used in the others below to determine if a key entered in a search like "email:[email protected]" | |
* is referencing the user_email column of the wp_users table or a unique meta key. | |
*/ | |
function my_pmpro_get_user_table_columns() { |
This file contains hidden or 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
# Stripe Webhook IPs via https://stripe.com/docs/ips#webhook-notifications | |
# v create a user/pass in this folder using htpasswd v | |
AuthUserFile /var/www/vhosts/domain.com/conf/.htpasswd | |
# ^^ | |
AuthType Basic | |
AuthName "Authentication Required" | |
Require valid-user | |
Order allow,deny | |
Allow from 3.18.12.63 | |
Allow from 3.130.192.231 |
This file contains hidden or 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 hidden or 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
/** | |
* Checking for membership when accessing non-WP pages. | |
* This code will work with the htaccess rewrite rules shared here: | |
* https://www.paidmembershipspro.com/locking-non-wordpress-files-folders-paid-memberships-pro/ | |
*/ | |
function my_pmpro_getfile_before_readfile( $filename, $file_mimetype ) { | |
if(is_dir($filename)) { | |
$filename .= "index.html"; | |
$mimetype = new pmpro_mimetype(); | |
$file_mimetype = $mimetype->getType($filename); |
This file contains hidden or 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 hidden or 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 hidden or 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 | |
/** | |
* When users expire (and the system changes them to membership level 0) we give them another downgraded level. | |
* This gist is setup to specifically downgrade level 6 to level 3 with an expiration set to 305 days out and | |
* downgrade level 5 to level 2 with an expiration set to 150 days out. | |
* Note that this code is using the pmpro_membership_post_membership_expiry hook which only fires when a user is expired | |
* by the PMPro cron job. If an admin changes the user's level or they cancel, they will not receive the downgraded level. | |
* Adjust the gist to meet your needs. | |
* Add this code to a custom plugin. https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ |