READ FIRST: This code needs to be added at the end of the functions.php file. If you are familiar with editing functions.php, feel free to continue reading. If you haven’t done this before, adding this code in the wrong place might bring the site down and the only way to access it is by editing functions.php file again via FTP. Feel free to contact us if you need help!
If you want to allow only a specific user group to access the referral link, i.e. editor role, add the following code to the functions.php file:
add_filter('wpgens_raf_code','gens_raf_code',10,1);
function gens_raf_code($raf_code) {
if( !current_user_can('editor')) {
return 'Referral code is available only to Editors';
}
return $raf_code;
}
add_filter('wpgens_raf_link','gens_raf_link',10,3);
function gens_raf_link($raf_link, $referral_id, $type) {
if( !current_user_can('editor')) {
return 'Referral link is available only to Editors';
}
return $raf_link;
}
add_action('wp','wpgens_custom_account_tabs');
function wpgens_custom_account_tabs(){
if( !current_user_can('editor')) {
$gens_plugin = WPGens_RAF::instance();
remove_filter( 'woocommerce_account_menu_items', array($gens_plugin->my_account,'gens_account_menu_item'),10);
}
}
Change the text to the one you want to show for other user roles.