Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active July 14, 2019 20:10
Show Gist options
  • Save amdrew/75fbd1a1e39737bedc01a3f46e0233d2 to your computer and use it in GitHub Desktop.
Save amdrew/75fbd1a1e39737bedc01a3f46e0233d2 to your computer and use it in GitHub Desktop.
<?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;
}
// Remove the logout menu item, since we want this last.
$logout = $items['customer-logout'];
unset( $items['customer-logout'] );
// Add the affilite area menu item.
// Assumes that affiliate-area is the correct page slug of the Affiliate Area
$items['affiliate-area'] = 'Affiliate Area';
// Add back the logout menu item.
$items['customer-logout'] = $logout;
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'affwp_custom_wc_menu' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment