Skip to content

Instantly share code, notes, and snippets.

<?php
function affwp_one_time_flat_rate_commission( $args, $amount, $order_id, $description, $affiliate_id, $visit_id, $products, $context ) {
if ( ! function_exists( 'affiliate_wp' ) ) {
return $args;
}
if ( 'flat' === affwp_get_affiliate_rate_type( $affiliate_id ) ) {
$args['amount'] = (float) affwp_get_affiliate_rate( $affiliate_id );
<?php
/**
* Adds "Affiliate Area" to WooCommerce's /my-account menu
*/
function affwp_custom_wc_menu( $items ) {
// return if user is not an affiliate.
if ( ! affwp_is_affiliate() ) {
return $items;
}
@amdrew
amdrew / auto-register.php
Created February 16, 2016 22:18
EDD Auto Register - change the length of the auto-generated password
<?php
function sumobi_edd_auto_register_filter_password_length( $args ) {
// change from the default of 32 to 10
$args['user_pass'] = wp_generate_password( 10 );
return $args;
}
add_filter( 'edd_auto_register_insert_user_args', 'sumobi_edd_auto_register_filter_password_length' );
<?php
function affwp_edd_block_commission_unless_purchased( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
// get referring affiliate ID
$affiliate_id = affiliate_wp()->tracking->get_affiliate_id();
// get user ID of referring affiliate
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
@amdrew
amdrew / affiliate-info.php
Last active May 22, 2022 20:54
AffiliateWP - Affiliate Info. Retrieve affiliate information via PHP function calls
<?php
$info = affiliatewp_affiliate_info()->functions;
$name = $info->get_affiliate_name();
$email = $info->get_affiliate_email();
$website = $info->get_affiliate_website();
$bio = $info->get_affiliate_bio();
$gravatar = $info->get_affiliate_gravatar();
$twitter = $info->get_twitter_username();
@amdrew
amdrew / force-scripts.php
Created October 1, 2015 22:02
AffiliateWP - Force front-end scripts for a particular page
<?php
function affwp_custom_force_frontend_scripts() {
if ( is_page( 123 ) ) {
return true;
}
}
add_filter( 'affwp_force_frontend_scripts', 'affwp_custom_force_frontend_scripts' );
@amdrew
amdrew / gist:248f571eff043c54bc7c
Created July 10, 2015 00:15
EDD + EDD Per Product Emails. Show a download's name as the email title
add_filter( 'edd_ppe_email_heading', '__return_true' );
@amdrew
amdrew / gist:7f22b058a5defb240c48
Last active March 15, 2016 14:41
OptimizeMember + AffiliateWP. Allow affiliates to login/register and still be redirected to the affiliate area
function affwp_custom_op_login_redirect( $return, $vars ) {
$user_id = $vars['user_id'];
if ( function_exists( 'affwp_is_affiliate' ) && affwp_is_affiliate( $user_id ) ) {
$return = false;
}
return $return;
}
@amdrew
amdrew / gist:a8be1db4d11774418714
Last active August 29, 2015 14:18
OptimizePress + AffiliateWP. Shows how to load a different shortcode for different pages
function affwp_opi_add_tracking_shortcode() {
// this can be the page ID, page slug, or page title. Page title is shown below
if ( is_page( 'Your Success Page' ) ) {
echo do_shortcode( '[affiliate_conversion_script description="Your Description" amount="100"]' );
}
// another "thanks" page using a page ID
if ( is_page( 50 ) ) {
echo do_shortcode( '[affiliate_conversion_script description="A different description" amount="200"]' );
@amdrew
amdrew / functions.php
Last active August 29, 2015 14:18
Cleans up the display of cross-sells and up-sells within the Marketify theme
/**
* Fix styling in the Marketify theme
*/
function sumobi_edd_csau_fix_styles() {
if ( ! ( is_singular( 'download' ) || edd_is_checkout() ) ) {
return;
}
?>
<style>