Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:8643ae9a2128490c0b05
Last active July 4, 2016 19:28
AffiliateWP - Send an email to the affiliate when their referral has been paid
/**
* Send email to affiliate when a referral has been paid
*/
function affwp_custom_affiliate_referral_paid_email( $referral_id, $new_status, $old_status ) {
if ( ! function_exists( 'affiliate_wp' ) || ( 'paid' != $new_status || 'unpaid' != $old_status ) ) {
return;
}
$referral = affiliate_wp()->referrals->get_by( 'referral_id', $referral_id );
@amdrew
amdrew / gist:8d76fe47178e9c46355e
Last active July 4, 2016 19:28
AffiliateWP - Auto enable affiliate referral notifications
/**
* Auto enable affiliate referral notifications
* Pre-selects the "Enable New Referral Notifications" checkbox on the "Settings" tab of the affiliate area when an affiliate either registers from the front-end, or is added from the admin
*/
function affwp_custom_auto_enable_affiliate_referral_notifications( $add ) {
update_user_meta( affwp_get_affiliate_user_id( $add ), 'affwp_referral_notifications', true );
}
add_action( 'affwp_insert_affiliate', 'affwp_custom_auto_enable_affiliate_referral_notifications' );
@amdrew
amdrew / gist:dd84effe45ee11b8b5e7
Created January 15, 2015 07:10
AffiliateWP - Add Namibian Dollar
// add the Namibian Dollar as a currency
function affwp_custom_add_namibian_currency( $currencies ) {
$currencies['NAD'] = 'Namibian Dollar';
return $currencies;
}
add_filter( 'affwp_currencies', 'affwp_custom_add_namibian_currency' );
// add the currency symbol before the amount
function affwp_custom_namibian_currency_symbol( $formatted, $currency, $amount ) {
$formatted = 'N$' . $amount;
@amdrew
amdrew / dashboard-tab-urls.php
Created January 14, 2015 03:28
AffiliateWP - Show the affiliate's username instead of affiliate ID in the affiliate dashboard
<?php
$affiliate = affwp_get_affiliate( affwp_get_affiliate_id() );
$user_info = get_userdata( $affiliate->user_id );
$affiliate_user_name = $user_info->user_login;
?>
<div id="affwp-affiliate-dashboard-url-generator" class="affwp-tab-content">
<h4><?php _e( 'Referral URL Generator', 'affiliate-wp' ); ?></h4>
<?php
/**
* [affiliate_referral_url_username] shortcode
*/
function affwp_custom_referral_url_shortcode( $atts, $content = null ) {
if ( ! affwp_is_affiliate() ) {
return;
}
@amdrew
amdrew / gist:e13a2a72de4b46a891ae
Created January 14, 2015 02:04
Easy Digital Downloads - Force account creation by cart total
<?php
/*
* Plugin Name: Easy Digital Downloads - Force account creation by cart total
* Description: Force account creation at checkout if the cart total is a certain amount
* Author: Andrew Munro
* Version: 1.0
*/
function sumobi_edd_force_account_creation_by_cart_total( $ret ) {
// enter the cart total amount that should force account creation
@amdrew
amdrew / gist:115ea3bfcfbcac7090cc
Last active August 29, 2015 14:13
Easy Digital Download - Force account creation if a download in cart has a specific download category or tag
<?php
/*
* Plugin Name: Easy Digital Downloads - Force account creation by category or tag
* Description: Forces the customer to create an account at checkout if a download in the cart has a specific download category or tag
* Author: Andrew Munro
* Version: 1.0
*/
function sumobi_edd_force_account_creation_by_download_category_or_tag( $ret ) {
// download categories that the download must belong to before account creation is forced
@amdrew
amdrew / gist:d0a9ef90b723b771f01b
Created January 13, 2015 03:02
AffiliateWP + WooCommerce. Show the customer's first and name last in the reference column on the referrals screen
/**
* Add link through to user's profile screen from the reference column of the referrals page
*/
function affwp_custom_wc_referrals_user_link( $reference, $referral ) {
if ( ! ( 'woocommerce' == $referral->context || class_exists( 'WC_Order' ) ) ) {
return $reference;
}
$order = new WC_Order( $referral->reference );
$customer_first_name = isset( $order->billing_first_name ) ? $order->billing_first_name : '';
@amdrew
amdrew / gist:dbfaa238900fb31d7b47
Created January 6, 2015 06:16
Easy Digital Downloads - add a {ip_address} email tag
<?php
/**
* Add a {ip_address} tag for use in either the purchase receipt email or admin notification emails
*/
if ( function_exists( 'edd_add_email_tag' ) ) {
edd_add_email_tag( 'ip_address', 'Customer\'s IP Address', 'sumobi_edd_email_tag_ip_address' );
}
/**
@amdrew
amdrew / gist:71d6880e7a1982889d02
Last active September 4, 2020 14:25
AffiliateWP - Leaderboard. Show the leaderboard via PHP function
<?php
/**
* Add this where you'd like the leaderboard to be displayed
*/
if ( function_exists( 'affwp_custom_show_leaderboard' ) ) {
affwp_custom_show_leaderboard();
}
?>