Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / gist:33cf7945590ca0f518e9
Last active August 29, 2015 14:03
Cleaning up bad user_activation_key values in WordPress.
#
# Sometimes when upgrading WP and/or moving between servers, user_activation_key values get out of whack.
# This query will remove ones with $ in it. WP will see the blank key and create a new good one.
#
UPDATE `wp_users` SET user_activation_key = '' WHERE user_activation_key LIKE '%$%'
@strangerstudios
strangerstudios / my_tc_menu_args.php
Created July 20, 2014 20:55
Members-only menu with Customizr Theme and Paid Memberships Pro.
/*
Add Members Only Menu for Customizr Theme
1. Add this code to your active theme's functions.php or a custom plugin.
http://www.paidmembershipspro.com/2012/08/create-a-plugin-for-pmpro-customizations/
2. Create a new menu called for members only.
3. Set the theme location to Main Menu (Members)
*/
@strangerstudios
strangerstudios / pmpro_changeMembershipLevel.php
Last active August 29, 2015 14:04
Example of calling pmpro_changeMembershipLevel with an array.
$level_id = 1;
$user_id = 1;
$level = pmpro_getLevel($level_id);
//set enddate if the level has one
if(!empty($level->expiration_number))
{
$custom_level = array(
'user_id' => $user_id,
'membership_id' => $level_id,
@strangerstudios
strangerstudios / my_pmpro_cancel_previous_subscriptions.php
Created July 21, 2014 19:05
Don't cancel PMPro subscriptions if a user's level is changed to another one in the admin.
<?php
/*
Don't cancel subscriptions if a user's level is changed to another one in the admin.
If set to "none" it will be cancelled though.
Add this code to your active theme's functions.php or a custom plugin.
*/
//filter cancellation
function my_pmpro_cancel_previous_subscriptions($cancel)
{
@strangerstudios
strangerstudios / ninja_forms_email_admin.php
Created July 28, 2014 14:13
Have a Ninja Form use the name and email entered as the reply to address.
<?php
/*
Update contact form to send "From" the user.
Assumes form #1 and that field #1 is the name and field #2 is the email address.
*/
add_action( 'ninja_forms_email_admin', 'pmpro_ninja_forms_change_from_address' );
function pmpro_ninja_forms_change_from_address(){
global $ninja_forms_processing;
if( 1 == $ninja_forms_processing->get_form_ID() ) {
@strangerstudios
strangerstudios / foundation_init.php
Last active August 29, 2015 14:05
Using the Foundation Framework in Your WordPress Theme
function foundation_init() {
wp_enqueue_style(
'bootstrap',
get_stylesheet_directory_uri() .
'/foundation/css/foundation.min.css',
'style',
'5.0'
);
wp_enqueue_script(
'bootstrap',
@strangerstudios
strangerstudios / pmprowc_membership_column_definition.php
Created August 31, 2014 22:48
Add a "Membership Level" column to the WooCommerce Products list in the dashboard when using PMPro WooCommerce and PMPro
/*
Membership Column for PMPro WooCommerce
*/
function pmprowc_membership_column_definition($columns)
{
if(!function_exists("pmpro_getLevel"))
return;
$columns['pmprowc_membership_level'] = __( 'Membership Level', 'pmpro' );
return $columns;
@strangerstudios
strangerstudios / my_pmpro_set_express_checkout_nvpstr.php
Created September 1, 2014 03:01
Setting LOCALECODE for PayPal Express with Paid Memberships Pro
function my_pmpro_set_express_checkout_nvpstr($nvpStr, $order)
{
$nvpStr .= "&LOCALECODE=en_US";
return $nvpStr;
}
add_filter('pmpro_set_express_checkout_nvpstr', 'my_pmpro_set_express_checkout_nvpstr', 10, 2);
@strangerstudios
strangerstudios / my_pmpro_after_change_membership_level.php
Created September 4, 2014 09:58
Change a user's bbPress Forum Role when their Paid Memberships Pro membership level changes.
/*
Give members participant role and others spectator.
1. Go to Settings --> Forums and change the "Auto role" to checked/Spectator.
2. Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
if($level_id == 0)
{
@strangerstudios
strangerstudios / my_iflychat_check_access.php
Last active August 29, 2015 14:06
Enable iflychat for Paid Memberships Pro members only.
function my_iflychat_check_access_filter($access)
{
if(!is_admin() && function_exists("pmpro_hasMembershipLevel") && !pmpro_hasMembershipLevel())
$access = false;
return $access;
}
add_filter('iflychat_check_access_filter', 'my_iflychat_check_access_filter');