Query or Function to add current blog id of newly created site to gravity forms redirect url

Using Prosites a previously registered user successfully creates a new multisite blog in gravity forms and I have them redirected to mysite.com/pro-site/ where they can now select the new site from a list of their sites to go to an upgrade page. The URL is like this: mysite.com/pro-site/?bid=73 (where bid=73 is the new blog's ID). Can I pass the ID of the newly created blog from the gravity forms submission and add its ID automatically to the end of the redirect URL after submit somehow to bypass the list of all sites?

Thanks for any help you can offer!

  • aristath

    Hello there @Kevin, I hope you're well today!

    To be honest I am not that familiar with Gravity forms myself as I have never used it, but I just wrote some code for you that will get the latest blog ID that a user has created.
    I hope you can use that to write your own custom code!

    $user_id = 1;
    $user_blogs = get_current_user_id();
    
    // This will get the latest blog created by the user.
    // This is based on the principal that blog IDs are incremental.
    // So new sites have a greater ID than previous one.
    foreach ( $user_blogs AS $user_blog ) {
    	// If variable is undefined, define it as this blogid.
    	if ( !isset( $latest_blog ) ) {
    		$latest_blog = $user_blog->userblog_id;
    	}else {
    		// I the current blog ID is greater then the variable,
    		// then change the variable.
    		if ( $latest_blog < $user_blog->userblog_id )
    			$latest_blog = $user_blog->userblog_id;
    	}
    }
    // This is the ID we're looking for
    $id = $latest_blog;

    I hope that helps!

    Cheers,
    Ari.

  • Kevin

    Ari, Thank for the code. I figured out an easy work around for this. I changed the confirmations redirect URL to http://{Site Domain:5}.mysite.com/wp-admin/

    Because the Prosite plugin restricts access to a new sites wp-admin until payment is made because I have the pay to blog feature enabled it redirects to the upgrade payment page for the blog, effectively adding the newly created blogs ID to the end of the url.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.