Auto pro sites credits in signup

Good day team
Is it possible to give users auto credits for pro sites when they sign up?
At sign up so I don't have to do it manually for each customer
Carpe diem
Robert

  • Vaughan

    Hi,

    It wasn't my intention to insult you.

    I've actually never used the bulk update feature before. So I wasn't aware of that. I apologise.

    The only options available are in the Bulk upgrade settings, where you can select the cost for x amount of credits which the member can purchase.

    Currently, there is no ability to assign credits during sign up, however, I will certainly add this to the features list & ask one of our SLS guys to see if there's a custom function which could be used to achieve this.

    Thanks

      • Tyler Postle

        Hey again Robert,

        Been awhile since we last spoke, I didn't realize Dominos Pizza was offering to have their developers look at customers website issues now :p

        As Vaughan alluded to, this isn't currently possible but we have flagged it for one of our SLS staff(coding experts) to take a look at and see if there is a realtively quick custom solution we can provide you, otherwise it would be something that you need to hire a developer for. We do have a members only jobs board for such situations if it comes to that: https://premium.wpmudev.org/wordpress-development/

        I do want to remind you from our last conversation where I mentioned if you continue to insult our staff then you would be permanently banned from our support, please keep that in mind. I realize we made a mistake on the first reply as Vaughan didn't know the credits module you were referring too but he did apologise for that and then flagged it for one of our developers since it requires a custom solution to auto-apply credits.

        One of us will reply back here once it has been looked into. Note that SLS deal with more advanced tickets so their responses can take longer than your typical support ticket. If you would rather not wait for our developer's feedback and you want to just hire someone right away then that's fine too, let us know and we'll call off our dev.

        Hope you have a great rest of your day/night.

        Cheers,
        Tyler

        • robertvideo

          Thanks Tyler
          Very nice to hear from you... no problem... I guess i just expected that he was a support person that knew the product otherwise why would he reply
          you can help me out with a HUGE HUGE serious issue on one of my accounts
          wordpresstestdrive.com out of my 60 plus accounts that work 100% this account keeps logging me out of WPMU dashboard and putting a padlock on it
          look at thread - its been going on for weeks and still not reply or solution
          a top level tech guy who I gave FTP and admin info to was supposed to help
          https://premium.wpmudev.org/forums/topic/wpmu-keeps-logging-me-out
          It was working again yesterday - did nothing different - NOW all day today it logs me out again - what do I do Tyler - Carpe Diem and great to hear form you - Robert

          • Tyler Postle

            Hey Robert,

            Nice to hear from you as well :slight_smile:

            Yeah, we support 100+ products, sometimes we don't get questions on certain features for months at a time - I often find myself re-testing certain features when asked about them just to refresh my memory. Occasionally I forget. Of course, we do our best to minimize those occasions!

            As for your other ticket, I'm going to follow up on that with the staff involved so we can get to the bottom of it asap. May need to get the developer involved. We'll update on that thread. Thanks for your patience.

            Cheers,
            Tyler

  • Mahlamusa

    Hello Robert,

    I hope you are doing great today and thank you for your patience so far. I am sorry for the late reply regarding this issue.

    I have written a code snippet to help you achieve this. I have tried various hooks to execute the during the initialization of WordPress but most of them do not seem to work as expected. The 'wpmu_activate_blog' filter seems to be the best option for executing the code.

    You can use the 'wpmu_activate_blog' filter as follows:

    add_filter('wpmu_activate_blog','callback_function_to_add_credits');
    function callback_function_to_add_credits(){
             update_user_meta( $user_id, 'supporter_credits', $new_credits_amount );
    }

    Please note that you have to get the '$user_id' and assign a value to '$new_credits_amount' which will be the number of credits you are assigning. You can add the above code snippet to your theme's functions.php file or create a .php file and upload it to 'wp-content/mu-plugins'.

    You may simply copy the following code and paste it to a new .php file, save it and upload the .php file to your website in the folder '/wp-content/mu-plugins/'. this will make sure the plugin will be executed automatically on your website without the need to activate it.

    <?php
    /*
    Plugin Name: Auto Credit on Signup
    */
    
    class Auto_Credits{
    	function __construct(){
    		if(is_multisite()){
    			add_filter('wpmu_activate_blog', array(&$this, 'auto_credits'), 10, 5);
    		}
    	}	
    
    	function auto_credits() {
    
    		$uid = get_current_user_id();
    		$credits = 100;
    		$old_credits = get_user_meta( $uid, "supporter_credits", true );
    		if ( empty( $old_credits ) || $old_credits < 0 ) {
    			$old_credits = 0;
    		}
    		$new_credits = $old_credits + $credits;
    		if ( empty( $new_credits ) || $new_credits < 0 ) {
    			$new_credits = 0;
    		}
    		error_log("Applying auto credits for user: $uid, credits: $credits, old credits: $old_credits, new credits: $new_credits");
    		update_user_meta( $uid, 'supporter_credits', $new_credits );
    	}
    }
    
    new Auto_Credits;

    Please note that this code will only execute when a new blog is activated since it is hooked to 'wpmu_activate_blog' filter. If it is a paid Pro Sites level this will occur after a successful payment regardless of which payment gateway was used. If you wish to try other action hooks or filters you may try adding the following lines of code inside the '__construct()' function:

    add_filter('wpmu_signup_user_notification', array(&$this, 'auto_credits'), 10, 3);
    add_filter('wpmu_signup_blog_notification', array(&$this, 'auto_credits'), 10, 3);
    add_filter('wpmu_activate_user', array(&$this,'auto_credits'), 10, 3);
    add_action('signup_finished', array(&$this,'auto_credits'), 10, 3 );
    add_action('supporter_payment_processed', array(&$this,'auto_credits'), 10, 3 );

    Add below or above the line:
    add_filter('wpmu_activate_blog', array(&$this, 'auto_credits'), 10, 5);

    So you will have the '__construct()' function look like this:

    function __construct(){
    		if(is_multisite()){
    			    add_filter('wpmu_activate_blog', array(&$this, 'auto_credits'), 10, 5);
                add_filter('wpmu_signup_user_notification', array(&$this, 'auto_credits'), 10, 3);
                add_filter('wpmu_signup_blog_notification', array(&$this, 'auto_credits'), 10, 3);
                add_filter('wpmu_activate_user', array(&$this,'auto_credits'), 10, 3);
                add_action('signup_finished', array(&$this,'auto_credits'), 10, 3 );
                add_action('supporter_payment_processed', array(&$this,'auto_credits'), 10, 3 );
    		}
    }

    I hope this helps you achieve your goals. If you need further help with this issue let us know, we are always happy to help you.

    I hope you enjoy your day further.

    Cheers,
    Mahlamusa