[Affiliates] Automatically make site owners Affiliates

I'm using a combination of Pro sites and Affiliates plugin, and I would like to make the sites owners becoming affiliates without having to click the link and automating the process, is this something you could help with?

  • Nithin
    • Support Wizard

    Hi ido,

    Hope you are doing good today. :slight_smile:

    At the moment, I'm afraid there isn't any out of the box settings to make it work automatically. I have escalated this ticket to our SLS team to check whether there is any quick workaround regarding this.

    Please do note that SLS works on complex issues, and have a slow response time. Will keep you posted once I get further updates regarding the status of the query asap. Have a nice day ahead. :slight_smile:


  • Konstantinos Xenos
    • Rubber Duck Debugger

    Hey ido ,

    Sorry for the late reply. I've made a mu-plugin to "connect" Pro Sites with Affiliates. Whenever there's a Pro Site creation triggered it will also check for the user and if they are not an affiliate it will automatically add them as one.

    How to install:
    Always make sure to keep a backup of your site before changing/adding custom code.

    1] Navigate to your /wp-content/ directory and create a new one named mu-plugins if it doesn't exist.
    2] Inside the mu-plugins folder create a file named prosites-affiliates.php
    3] Edit the file and copy / paste this code snippet inside.

    	function( $blog_id ) {
    		if ( function_exists( 'aff_build_reference' ) ) {
    			$blog_details = get_blog_details( $blog_id );
    			global $wpdb;
    			$results = $wpdb->get_results(
    					"SELECT <code>user_login</code>, <code>domain</code>, <code>path</code>
    					FROM {$wpdb->signups}
    					WHERE <code>domain</code> = %s
    					AND <code>path</code> = %s",
    			$user = get_user_by( 'login', $results[0]->user_login );
    			if ( get_user_meta( $user->ID, 'enable_affiliate', true ) !== 'yes' ) {
    				$reference = aff_build_reference( $user );
    				update_user_meta( $user->ID, 'affiliate_reference', $reference );
    				update_user_meta( $user->ID, 'affiliate_hash', 'aff' . md5( AUTH_SALT . $reference ) );
    				update_user_meta( $user->ID, 'enable_affiliate', 'yes' );
    				update_user_meta( $user->ID, 'affiliate_paypal', '' );

    4] Save and close the file.
    5] The final path should look like /wp-content/mu-plugins/prosites-affiliates.php
    6] Everything should work after that automatically.

    Tell me if you need any further help with this!


  • ido
    • The Incredible Code Injector

    Hey Konstantinos,

    Wow, thanks a lot for this,

    I thought you forgot about me and I got a freelancer working on integrating Pro-Sites with ThriveCart (that has a built-in affiliate system).

    Thanks again,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.