View my_pmpro_pre_handle_404.php
/* | |
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; | |
//bail if PMPro is not installed | |
if(empty($wpdb->pmpro_discount_codes_levels)) |
View pmpro_queries_with_period_vars.sql
SET @p1start = '2016-04-01'; | |
SET @p1end = '2016-07-01'; | |
SET @p2start = '2017-04-01'; | |
SET @p2end = '2017-07-01'; | |
#period 1 | |
select CONCAT('Period 1, ', @p1start, ' to ', @p1end) AS ''; | |
# new paid orders | |
SELECT COUNT(DISTINCT(mo1.id)) |
View pmpro_queries.sql
# successful paid orders for a given month | |
SELECT COUNT( * ) | |
FROM wp_pmpro_membership_orders | |
WHERE | |
total > 0 AND | |
status NOT IN ( | |
'error', 'token', 'refund', 'pending', 'review' | |
) | |
AND TIMESTAMP > '2017-10-01' | |
AND TIMESTAMP < '2017-11-01'; |
View pmpro_clear_enddates.sql
# oops I had PMPro setup with recurring subscriptions AND expiration dates | |
# I really didn't need the expiration date because the subscription is managed by the gateway | |
# if payment fails, the gateway will try again based on its settings | |
# and when the gateway gives up, it will tell PMPro through IPN/webhook to cancel the subscription | |
# If I have expiration dates setup for recurring subscription, PMPro is going to cancel those subscriptions | |
# whether they pay or not. So I need to edit the level and remove the expiration date AND | |
# run this script to clear out the end dates for active subscriptions. | |
#### | |
# BACK UP YOUR DATABASE FIRST | |
#### |
View my_pmpro_affiliatewp_after_change_membership_level.php
<?php | |
/* | |
Creates an affiliate for new members of Level ID 1. | |
Updates affiliate status if the affiliate already exists. | |
Sets affilaite status to 'inactive' if membership of Level ID 1 is cancelled (includes expiration). | |
Add this code to a custom plugin. | |
*/ | |
function my_pmpro_affiliatewp_after_change_membership_level( $level_id, $user_id, $cancel_level ) { | |
//make sure affiliatewp is active |
View my_pmpro_level_cost_text_for_ab_test.php
/* | |
Set a cookie when users enter a specific page. | |
(You would setup Google Experiments or your A/B testing software | |
to send 50% of visitors to this page.) | |
*/ | |
function my_wp_set_cookie_for_ab_test() { | |
if(is_page('pricing-2')) { | |
setcookie('ab_test_group_2', 1, 0, COOKIEPATH, COOKIE_DOMAIN, false); | |
} | |
} |
View pmpro_is_level_expiring_soon_yes_on_levels_page.php
/* | |
Show a renew link instead of Your Level | |
for recurring subscriptions on the levels page. | |
Add this code to a custom plugin. | |
*/ | |
function pmpro_is_level_expiring_soon_yes_on_levels_page($expiring) { | |
//only adjust this on the levels page so we don't mess anything up | |
global $pmpro_pages; | |
if(!is_admin() && !empty($pmpro_pages) && is_page($pmpro_pages['levels'])) |
View pmpro_email_filter_checkout_from_users.php
/* | |
Have admin checkout emails come from the customer. | |
Add this code to a custom plugin. | |
*/ | |
function pmpro_email_filter_checkout_from_users($email) | |
{ | |
if(strpos($email->template, 'checkout') !== false) { | |
//get user info | |
$user = get_user_by('login', $email->data['user_login']); |
View mainenance_mode_on.php
/* | |
Lock site down to just our IP | |
Create a file /maintenance.html that explains that maintenance mode is on. | |
Update your IP address in the line below. | |
Add this code to your active theme's functions.php or a custom plugin. | |
*/ | |
function mainenance_mode_on() { | |
if($_SERVER['REMOTE_ADDR'] == 'YOURIPADDRESSHERE') //find your IP and edit here | |
return; |
View my_custom_disable_admin_bar.php
/* | |
Disable the admin bar for any user who is not admin, | |
can't edit users and can't edit posts. | |
Add this code to a custom plugin. | |
*/ | |
function my_custom_disable_admin_bar() { | |
if(!current_user_can('administrator') && !current_user_can('edit_users') && !current_user_can('edit_posts')) { | |
add_filter( 'show_admin_bar', '__return_false' ); | |
add_action( 'admin_print_scripts-profile.php', 'habfna_hide_admin_bar_settings' ); | |
} |
NewerOlder