The MU forums have moved to WordPress.org

Getting Owner's ID (7 posts)

  1. unknownserv
    Member
    Posted 16 years ago #

    Does anyone know any way to get the blog owner's ID (I.E, a function so it can be used in a plugin, or an SQL query, I don't mind which)?
    I'm modding the friends plugin to be mutual, and could do with a way to find the blog owner's ID.

    Thanks.

  2. drmiketemp
    Member
    Posted 16 years ago #

    The problem with trying to get that is that a blog may be owned by more than one person.

    I can't pull up code from here (Locked down, single window dumb terminal) but take a look at the wp-admin/users.php page and see how the software pulls up the list of admins for a blog. That should get you started.

  3. unknownserv
    Member
    Posted 16 years ago #

    Hmm, that is a problem. I think i've got a way to get the primary owner tho:
    function get_blogowner() {
    global $wpdb;
    if(get_option('siteurl') != 'http://your.main.url') {
    $siteurl = str_replace('http://','',get_option('siteurl'));
    $siteurl = str_replace('/','',$siteurl);
    $user_login = $wpdb->get_var("SELECT user_login FROM wp_signups WHERE domain='".$siteurl."';");
    $user_id = $wpdb->get_var("SELECT id FROM wp_users WHERE user_login='".$user_login."';");
    $blogowner = $user_id;
    } else {
    $blogowner = '1';
    }
    return $blogowner;
    }

  4. xiand0
    Blocked
    Posted 16 years ago #

    unknownserv, http://nadia.xiando.com/xiando-friends-list.tar.bz2 is my version which is muteral.

    Beware that the version you are apparently trying to modify actually stores the BLOG ID (current_blog) as "friends". So you're not making friends of a person ($current_user, username). I know since I remember changing it so you make friends with usernames, not blogs (however, the friends-list one at wpmudev can be used to make a "Subscribe to blog" feature since that's really what it actually stores).

    Regarding getting "Does anyone know any way to get the blog owner's ID",

    You must have access to the

    global $wpdb, $blog_id, $wpmuBaseTablePrefix;

    then you can just SQL query the post_author:

    $blogownerid = $wpdb->get_var("SELECT post_author FROM " . $wpmuBaseTablePrefix . $blog_id . "_posts");

    How you have the ID and you can do all sorts of things with it, like $userdata = get_userdata($blogownerid);

  5. unknownserv
    Member
    Posted 16 years ago #

    Thanks, I'll see how I get on with my version as I'd prefer "friends" to be blogs instead of users, if you know what I mean (As I'm going to mod it so that certain blogs [or friends] are classed as a club).

  6. mrjcleaver
    Member
    Posted 16 years ago #

    On #wpmu today:

    (12:39:39) MartinCleaver: There's this line:
    (12:39:43) MartinCleaver: $blogownerid = $wpdb->get_var("SELECT post_author FROM wp_" . $blog_id . "_posts");
    (12:40:03) MartinCleaver: which says that the id of first person to post is considered the blog owner
    (12:40:20) MartinCleaver: but the first user to post is admin, not the blog owner
    (12:40:40) MartinCleaver: why didn't they use the api?
    (12:40:54) MartinCleaver: that's taken like 3 hours to solve
    (12:41:39) donncha: wow, that is bad

  7. Konstan
    Member
    Posted 16 years ago #

    Where is #wpmu located? I have some questions I wouldnt mind having an answer to :)

About this Topic

  • Started 16 years ago by unknownserv
  • Latest reply from Konstan