The MU forums have moved to WordPress.org

Get the blog ID (10 posts)

  1. daniminas
    Member
    Posted 18 years ago #

    Hello, in a plugin, how can i get the current blog ID?

    Thanks! :)

  2. daniminas
    Member
    Posted 18 years ago #

    Autoreply: $wpdb->blogid... :)

  3. drmike
    Member
    Posted 18 years ago #

    Actually I believew $blog_id is also carried as a global variable though most of the system. I'm not calling it but it works when I want it to. :)

  4. jesper2000
    Member
    Posted 17 years ago #

    I finally figured out how to hack geekgrrl's profile picture plugin (http://geekgrl.net/2007/01/02/profile-pics-plugin-release/) to enable users to upload their own header into their theme.

    All I need is a function that echoes the blogID.

    I have the directory: /wp-content/blogs.dir/1.jpg, but I would like to replace the value "1" with:

    /wp-content/blogs.dir/<? echo ('get_blogID'); ?>.jpg

    if that were possible. I'm not a PHP-coder, but will of course post the solution, if you could help me...

  5. jesper2000
    Member
    Posted 17 years ago #

    Proposed solution to letting users on a wpmu-site upload their own header image into the default template:

    1. Upload profile-pictures.php from geekgrl into the mu-plugins folder
    2. Options -> Profile Pics Upload Directory, (defaulted to: "/wp-content/blogs.dir/" instead of "wp-content/uploads/authors/" (line 13)
    3. Comment: this places alle the header pictures in blog.dir directory as 1.jpg, 2.jpg and so forth, corresponding to the blog ID of the uploader...

    4. Missing link in header.php
      ...

      style="background-image:url(wp-content/blogs.dir/
      <?php echo ('$wpdb->blogid') ?>.jpg);">

      ...

    5. $wpdb->blogid: to be replaced with echo of the blogID...

    6. And of course: change the copywriting on the profile page ("upload your header picture here"), and offer Sam Devols About Me widget as an alternative to geekgrl's original intention...
  6. WDuluoz
    Member
    Posted 17 years ago #

    Couldnt you just use something similar to k2's interface. It allows you to upload pictures for headers and even do a random picture.

    I hacked geekgirl's profile picture to use as an avatar system. Works pretty decently.

    I used a common directory and the user_ID to pull the correct picture.

    WDuluoz

  7. jesper2000
    Member
    Posted 17 years ago #

    Yeah, but haven't got around to looking at k2+wpmu yet, expecting it to be simpler to just figure out (-> ask) how to echo the blogID...

  8. lunabyte
    Member
    Posted 17 years ago #

    global $blog_id;
    echo $blog_id;

    Nothing spectacular about that.

  9. jesper2000
    Member
    Posted 17 years ago #

    Thanks Lunabyte!

    <div id="header"><h1><a href="<?php bloginfo('home'); ?>"
    style="background-image:url(wp-content/blogs.dir/
    <?php global $blog_id; echo $blog_id; ?>.jpg);">
    <?php bloginfo('name'); ?>
    </a></h1></div>

    - gets the header image corresponding to the user that uploaded the picture...

  10. CoreyCampbell
    Member
    Posted 17 years ago #

    This is nice... but one side is using the user_id and the other is using the blog_id. Now if a user makes just a username it throws everything off. Any fixes?

About this Topic

  • Started 18 years ago by daniminas
  • Latest reply from CoreyCampbell