Pro Sites - Get current site plan ID and start date.

Hello

Is it possible, via PHP, to get the following:
- Current website plan ID/details.
- The date in which the current website was created.

Thanks

Elliot

  • Oguz

    Hey Elliot Sowersby,

    Hope you are doing fine today!

    To get the created date for a site, you can use get_blog_details() function. This function is not related with Pro Sites plugin, It's WordPress function. You can look how it's working from the Codex Page. Basically you can give site ID then the function returns an object which has all the necessary information. There is "registered" property which is created date of that site. You can use like this;

    $blogdetails = get_blog_details($blog_id);
    $created = $blogdetails->registered;

    For the get site plan, you can use get_level function of the global $psts object. Like;

    global $psts;
    $level = $psts->get_level( $blog_id );

    Besides all of that, I want to share how you can get user sites too. To get current logged in user id you can use get_current_user_id() function and to get all the sites of the user you can use get_blogs_of_user($user_id) function. Again these are just WordPress core functions and you can use like;

    $user_id = get_current_user_id();
    $user_sites = get_blogs_of_user($user_id);

    But don't forget to use this functions at least with init action. Otherwise, you can't reach a current user.

    If you have any additional questions please let me know and I’ll be happy to help.
    Cheers!
    Oguz

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.