Skip to content

Instantly share code, notes, and snippets.

@amdrew
amdrew / gist:70aefa5d77da9f858b73
Last active August 29, 2015 14:17
AffiliateWP - change headers
function affwp_custom_email_headers( $headers ) {
// change this to be your new site name
$from = 'Your new site name';
// change this to your email address that the email should come from
$email = '[email protected]';
$headers[] = 'From: ' . $from . ' <' . $email . '>';
/**
* AffiliateWP - login and redirect affiliates to affiliate area
* All other users are redirected to the site's homepage
*
* Works when user logs in via the page where the [affiliate_login] shortcode is used
* Works when affiliate logs in via wp-login.php page so they don't see the admin
*/
function affwp_custom_login_redirect( $user_login, $user ) {
$user_id = $user->ID;
/**
* Restrict quantity of download at checkout
*/
function sumobi_edd_restrict_download_quantity( $valid_data, $post ) {
$download_id = 50;
$max_number = 4;
$cart_contents = edd_get_cart_contents();
<?php
/**
* Change the referral email
*/
function affwp_emails_referral_email( $message, $args ) {
$email = affwp_get_affiliate_email( $args['affiliate_id'] );
$amount = html_entity_decode( affwp_currency_filter( $args['amount'] ), ENT_COMPAT, 'UTF-8' );
$message = sprintf( __( "Congratulations %s!\n\n", "affiliate-wp" ), affiliate_wp()->affiliates->get_affiliate_name( $args['affiliate_id'] ) );
<?php
$affiliate_wp = affiliate_wp();
remove_shortcode( 'affiliate_area', array( $affiliate_wp, 'affiliate_area' ) );
add_shortcode( 'affiliate_area', 'affwp_custom_affiliate_area' );
function affwp_custom_affiliate_area() {
ob_start();
@amdrew
amdrew / gist:da4d7a7641415757d793
Created February 12, 2015 04:15
Easy Digital Downloads + FES. Filter the TOS field to remove the textarea so you can link to a separate page in a new window
<?php
function sumobi_fes_tos( $field, $form_vars, $id, $type, $form_id, $read_only, $args ) {
ob_start();
?>
<div class="fes-fields">
<span data-required="yes" data-type="radio"></span>
<label>
<input type="checkbox" name="fes_accept_toc" required="required" /> <a href="<?php echo site_url( 'my-terms' ); ?>" target="_blank">Accept My Terms
</label>
@amdrew
amdrew / gist:6d98891e0a958f71240f
Created February 9, 2015 08:46
Easy Digital Downloads - Add download to cart if the cart is empty
<?php
/**
* Add product to cart if cart is empty
*/
function sumobi_edd_add_to_cart_if_empty() {
$download_to_add = 123;
$cart = function_exists( 'edd_get_cart_contents' ) ? edd_get_cart_contents() : false;
@amdrew
amdrew / gist:0bf426db10668a971faa
Last active August 29, 2015 14:14
Easy Digital Downloads - Add twitter field to EDD Register form and save it to usermeta
/**
* Add new twitter field to EDD register form
*/
function sumobi_edd_add_registration_field() {
?>
<p>
<label for="edd-user-twitter-username"><?php _e( 'Twitter Username', 'edd' ); ?></label>
<input id="edd-user-twitter-username" class="edd-input" type="text" name="edd_user_twitter_username" />
</p>
@amdrew
amdrew / gist:44322e0c35ef307be1bc
Last active July 22, 2024 14:41
Passes affiliate referral parameters from the URL of the static HTML page and automatically appends them to any URLs that match the target URL (where AffiliateWP is installed) defined in the JavaScript. Also stores the value in a cookie so will work across multiple static HTML pages on the same site (each page must have the same script). Current…
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Landing page</title>
</head>
<body>
@amdrew
amdrew / gist:8314e3108d1ce799c291
Last active September 5, 2024 01:50
Easy Digital Downloads - Frontend Submissions - Pay To Upload. Forces the vendor to pay for each file uploaded before the product is published
<?php
/**
* Plugin Name: Easy Digital Downloads - Frontend Submissions - Pay To Upload
* Plugin URI:
* Description: Forces the vendor to pay for each file uploaded before the product is published
* Author: Andrew Munro
* Author URI: http://sumobi.com
* Version: 1.0
*/