[Affiliate plugin] Affiliate plugin - limiting who can be an affiliate

On our Membership 2.0 site - videobiker.co.uk - we need an affiliate solution and have been considering the WPMUDEV plugin. Important question - we need to be able to limit which of our site users can be affiliates, such that we 100% control who can join as an affiliate. Does this plugin cater for this please?

  • Nahid

    Hey Jez !
    Hope you are having a great day!

    The Affiliates plugin lets every registered user of the site to be an affiliate from their WordPress Dashboard->Profile->Affiliate Referrals. Unfortunately, you won't be able to restrict certain users from having affiliate capabilities out of the box. There are 'Approval Settings' in the plugin, letting you control which affiliates are approved to receive payouts. Turning this setting on will require you to manually approve each affiliate. They will still be able to generate leads using their Affiliate capabilities, but they won't be eligible to receive payouts until they are manually approved. Here's a screenshot for reference:

    Another workaround regarding your request would be using a plugin like User Role Editor, where you can specify the affiliate user capabilities to a certain user role. In that case, users only with that specific user role will be able to become affiliates.

    Hope this helps. Let us know if you need any further assistance regarding this. Thanks!

    Kind regards,
    Nahid

  • Nahid

    Hey Jez !
    Hope you are doing well today!

    I just tried using the 'User Role Editor' plugin to restrict users belonging to certain user roles from accessing the Affiliates plugin. Unfortunately, it didn't work as I expected as the Affiliates plugin didn't add any additional capabilities to the users that we can remove from the preferred user role(s). I'm sorry about the confusion and I apologize for recommending the untested workaround.

    I discussed with one of our developers about this and they came up with another probable workaround that you can test out. It'd require you to add the following code into the functions.php file of your theme (most preferably, child theme):

    add_action( 'admin_menu', function(){
        global $affadmin;
    
        if ( ! $affadmin instanceof affiliateadmin ){
            return;
        }
    
        $page = remove_submenu_page( 'profile.php', 'affiliateearnings' );
        add_submenu_page( 'users.php', __( 'Affiliate Earnings Report', 'affiliate' ), __( 'Affiliate Referrals', 'affiliate' ), 'edit_private_posts', "affiliateearnings", array(
            $affadmin,
            'add_profile_report_page'
        ) );
    
    }, 999 );

    You can also add the code in a mu-plugin. That'll require you to paste the mentioned code in a PHP file that ends with the extension .php, e.g. "anyname.php". The mentioned code should have a "<?php" definition at the start of the file. This PHP file should be placed in {your root WordPress folder}/wp-content/mu-plugins (you'll need to create the folder named "mu-plugins" if it is not there already).

    Let me explain what this code should do. This should remove the Affiliates menu item from the users' admin menu except for those belonging to the user roles having the 'edit_private_posts' capability (only Administrator and Editor roles have that capability by default). You can see the capability definition in line number #9 of the mentioned code. You can change 'edit_private_posts' to any other unique capability that your preferred user role contains so that users belonging to those user roles can only access the Affiliates plugin.

    Hope this helps. Let us know if this works for you. Thanks!

    Kind regards,
    Nahid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.