Skip to content

Instantly share code, notes, and snippets.

Avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / gist:d973776836ab984aea06
Created Sep 3, 2014
Sets an affiliate user's role to a specific role when being added as an affiliate
View gist:d973776836ab984aea06
<?php
/*
* Plugin name: Affiliate role on registration
*/
function pw_affwp_set_role_on_registration( $affiliate_id = 0 ) {
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
$user = new WP_User( $user_id );
$user->add_role( 'affiliate' );
@pippinsplugins
pippinsplugins / gist:9557012
Created Mar 14, 2014
Send an email anytime a payment is recurring through EDD Recurring Payments
View gist:9557012
<?php
function pw_edd_recurring_payment_received_notice( $payment, $parent_id, $amount, $txn_id, $unique_key ) {
$user_id = edd_get_payment_user_id( $parent_id );
$email = edd_get_payment_user_email( $parent_id );
$user_data = get_userdata( $user_id );
$subject = 'Payment Received';
$message = "Hello $usera_data->display_name, your payment for $amount has been received. Thanks!";
View gist:4503579
<?php
function pw_edd_send_email_on_pending( $payment_id, $payment_data ) {
// grab the gateway so we can only send on email for specific gateways
$gateway = isset( $_POST['edd-gateway'] ) ? $_POST['edd-gateway'] : '';
// TODO: replace "bacs" with your gateway ID
if( $gateway != 'bacs' )
return;
@pippinsplugins
pippinsplugins / edd-slack-slash-command.php
Last active Jul 11, 2021 — forked from jameslaws/edd-slack-slash-command.php
A Slash command to retrieve earnings in Restrict Content Pro for the specified time period. Based on http://wpninjas.com/using-slack-slash-commands-to-get-edd-sales-info/
View edd-slack-slash-command.php
<?php
function pw_rcp_earnings_slash_command() {
# Check to make sure this is a Slash Command Request
if ( ! isset( $_REQUEST['slack_slash'] ) && 'your_custom_string' != $_REQUEST['slack_slash'] )
return false;
# Check to see if a token has been passed as well
if ( ! isset( $_REQUEST['token'] ) )
@pippinsplugins
pippinsplugins / gist:11402562
Last active Nov 27, 2020
Custom user fields for Restrict Content Pro
View gist:11402562
<?php
/*
Plugin Name: Restrict Content Pro - Custom User Fields
Description: Illustrates how to add custom user fields to the Restrict Content Pro registration form that can also be edited by the site admins
Version: 1.0
Author: Pippin Williamson
Author URI: http://pippinsplugins.com
Contributors: mordauk
*/
@pippinsplugins
pippinsplugins / gist:ececad5d57e3946c5af3
Last active Sep 24, 2020
Adds billing address fields to Restrict Content Pro
View gist:ececad5d57e3946c5af3
<?php
/**
* Plugin Name: Restrict Content Pro - Collect Billing Address
* Description: Collect customers billing address during registration through Restrict Content Pro
* Author: Pippin Williamson
* Version: 1.0
*/
class RCP_Billing_Address {
@pippinsplugins
pippinsplugins / edd_grid.php
Last active Apr 24, 2020
sample Easy Digital Downloads Product Grid with Pagination
View edd_grid.php
<?php get_header(); ?>
<div id="main-content" class="row store-template">
<div class="content clearfix">
<?php
$current_page = get_query_var('paged');
$per_page = get_option('posts_per_page');
$offset = $current_page > 0 ? $per_page * ($current_page-1) : 0;
$product_args = array(
'post_type' => 'download',
View edd-heartbeat-demo.php
<?php
/**
* Plugin Name: EDD Heartbeat API test plugin
* Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard
*/
// Load the heartbeat JS
function edd_heartbeat_enqueue( $hook_suffix ) {
// Make sure the JS part of the Heartbeat API is loaded.
wp_enqueue_script( 'heartbeat' );
View gist:9641841
<?php
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
@pippinsplugins
pippinsplugins / edd_email_conf.php
Last active Dec 17, 2019
Add email confirmation to EDD
View edd_email_conf.php
<?php
function pw_edd_add_email_confirmation() {
?>
<p>
<label class="edd-label" for="edd-email-confirm">
<?php _e('Confirm Your Email Address', 'easy-digital-downloads'); ?>
<span class="edd-required-indicator">*</span>
</label>
<span class="edd-description" id="edd-email-description"><?php esc_html_e( 'Please confirm your email address.', 'easy-digital-downloads' ); ?></span>