Skip to content

Instantly share code, notes, and snippets.

View 1wdtv's full-sized avatar

1WD.tv - Make Money With Divi 1wdtv

View GitHub Profile
@strangerstudios
strangerstudios / update_membership_id.sql
Created July 28, 2015 12:31
SQL to change the membership of active PMPro membership from one level to another.
#make sure to change the 20 and 6 below to the ending and starting IDs of your levels respectively.
UPDATE wp_pmpro_memberships_users SET membership_id = 20 WHERE membership_id = 6 AND STATUS = 'active';
@CoachBirgit
CoachBirgit / divi-sticky-footer.css
Last active January 6, 2018 02:11
CSS: Sticky footer - Elegantthemes Divi
@eri-trabiccolo
eri-trabiccolo / menu_item_attr_manipulation.php
Created May 13, 2015 08:59
Menu item attribute manipulation
add_filter( 'nav_menu_link_attributes', 'menu_item_data_toggle', 10, 2 );
function menu_item_data_toggle( $atts, $item) {
// Manipulate attributes
if ( 74 == $item -> ID )
$atts['data-toggle'] = 'modal';
return $atts;
}
@ultimatemember
ultimatemember / gist:48bf0a269af5d182ad9b
Created May 4, 2015 19:15
UM/EDD Open Metrics: Show various sale stats
// Avg downloads per customer
function sc_edd_avg_downloads_per_customer( $atts ) {
$amount = 0;
$query = new WP_Query( array( 'post_type' => 'download' ) );
foreach( $query->posts as $post ) {
$amount = $amount + edd_get_download_sales_stats( $post->ID );
}
$amount = $amount / edd_count_total_customers();
return number_format( $amount, 2 );
}
<?php
/*
Plugin Name: PMPro stop downgrade level
Plugin URI: https://gist.github.com/1wdtv/a6d8a45979e4e217d212
Description: Prevent existing paid members from downgrading to free level (eg: when registering from a webinar).
Version: 1
Author: 1WD.tv
Author URI: https://1wd.tv
*/
/*
@strangerstudios
strangerstudios / my_template_redirect_upgrade.php
Created April 14, 2015 16:12
Redirect away from the checkout page if you don't have a required level with Paid Memberships Pro.
/*
Redirect away from the checkout page if you don't have a required level.
*/
function my_template_redirect_upgrade()
{
global $pmpro_pages, $pmpro_level;
if(empty($pmpro_pages))
return;
@strangerstudios
strangerstudios / my_pmpro_registration_checks.php
Created April 14, 2015 16:08
Require a certain level before registering for another level with Paid Memberships Pro.
/*
Require a certain level before registering for another level.
Add this code to your active theme's functions.php or
a custom plugin.
*/
function my_pmpro_registration_checks($okay)
{
//only check if things are okay so far
if($okay)
{
@strangerstudios
strangerstudios / my_pmpro_wp_ajax_memberlist_csv_cron.php
Created April 8, 2015 17:44
Run members list CSV export without logging in as long as you know the secret key.
/*
Run members list CSV export without logging in
as long as you know the secret key.
Important: Change the "secret key" below to something unique for your site.
Add this code to your active theme's functions.php or a custom plugin.
Set your cron to hit /wp-admin/admin-ajax.php?action=memberslist_csv_cron&secret={YOUR SECRET KEY}
*/
@strangerstudios
strangerstudios / my_pmpro_email_headers_admin_emails.php
Last active January 26, 2022 18:07
BCC an additional email on PMPro admin emails.
/*
Add bcc for PMPro admin emails
*/
function my_pmpro_email_headers_admin_emails($headers, $email)
{
//bcc emails already going to admin_email
if(strpos($email->template, "_admin") !== false)
{
//add bcc
$headers[] = "Bcc:" . "otheremail@domain.com";
@butlerblog
butlerblog / auto-login-from-reg-email.php
Last active November 14, 2024 11:08
WordPress auto login from native registration email
<?php
/*
This code snippet can be added to your functions.php file (without the <?php)
to add a query string to the login link emailed to the user upon registration
which when clicked will validate the user, log them in, and direct them to
the home page.
*/
/**
* This first function is hooked to the 'user_register' action which fires