Get Blog Owner retrieves owner information for a WordPress MU blog in a standard user information object, or retrieves an array of all blog owners, with key matching blog ID.

Version 1.0 added August 17, 2009!

Download version 1.0 from the WordPress MU plugin repository »

Description

Retrieve user information for blog owners in a basic WordPress MU environment. Can retrieve the current blog owner’s user information, specify the blog by ID, or retrieve owner information for all of the blogs in an array!

Easily integrated with any template by using the two functions provided by the plug-in: get_blog_owner and get_blog_owners.

When retrieving multiple owners, you can specify the number of owners to return and sort by blog creation date, most active blogs, or most recently updated blogs; the key for each item in the returned array matches the ID of the blog!

Practical uses include featuring the blog owners (perhaps by most active blogs) in a site wide template, or highlighting the blog owner inside their individual blog.

Installation & Usage

To install, just upload the single PHP file (mu_blog_owner.php) to the “mu-plugins” folder under “wp-content”.

To show the owner of a single blog, use the get_blog_owner() function, which accepts two optional parameters:

  • blog id – The numeric ID of the blog whose owner information you would like to return (defaults to the current blog).
  • one result – By default, the plug-in will attempt to match the blog administrative email address with an email address in the users table; if this fails, it will pull all blog users with full administrative (level 10) permissions. In the latter case, its possible that it can return more that one result. By default, the plug-in will return the first result; set this parameter to false to return an array of users with administrative permissions if more than one user is found (defaults to true; returns only the first user)

For instance, if you want to store the user information for the current blog’s owner in a variable called user_info:

$user_info = get_blog_owner();

To retrieve a list of blog owners, use get_blog_owners() (with an “s” at the end; owners), which accepts two optional parameters:

  • order by – Set to “reg_date” to sort by date of blog creation, with the newest blogs at the top; “last_updated” sorts by the latest update (not last published post, last update) with most recently updated blogs at the beginning; “most_active” sorts by the most active blog (defaults to “reg_date”).
  • number – The number of blog owners to return; use “all” to return all blog owners, or an integer for the number you would like to return (defaults to “all”).

The key for each item in the returned array of user objects matches the ID of the blog for which the user is the owner. Note that this function calls the get_blog_owner function using the “one_result” parameter set to true.

For instance, if you want to store the user information for the owner of the last 10 updated blogs in a variable called blog_owners:

$blog_owners = get_blog_owners("last_updated",10);

Note that full user information is returned using the standard WordPress get_userdata() function, meaning the standard user information object is returned.

This has only been fully tested with WordPress MU 2.8.1 and newer. It is expected to work in earlier builds, including 2.7, but has not been tested.

As always, feedback and suggestions are welcome!

4 Responses to “Get Blog Owner (WordPress MU Plugin)”

  1. Get blog owner information plugin « Plugin Test blog says:

    [...] Neat new plugin over at WPMU DEV.org by Jake of (I assume) C Murray Consulting [...]

  2. Much thanks for developing this functionality. downloading it now to see if once I pull the blog owner information it provides whether or not the blog owner is logged in at the time. Hopefully this will provide me a path to easily check!

    Kenneth Stein

  3. Kirk Ward says:

    Could this plugin be used to customize the welcome email that is sent to new blog owners? If so, how would it be done? (I can follow instructions, but I am not a coder.)

    Kirk

  4. Jake Goldman says:

    Not sure, Kirk. What exactly are you trying to do?