The MU forums have moved to WordPress.org

$current_user in WPMU (4 posts)

  1. YellowSwordfish
    Member
    Posted 13 years ago #

    My forum plugin has been successfully working in standard and MU versions of WP. I am soon to release a major upgrade and I have some MU problems. I now make extensive use of the $current_user object.

    For php files that are not included I have been including config.php and declaring $current_user as global so I have access to its values.

    This has been fine in standard WP but in MU I find that $current_user is empty.

    is anyone able to tell me what I should be doing to get at the $current_user object in these circumstances?

  2. boonika
    Member
    Posted 13 years ago #

    This function should be applied for all or just for the main blog?

  3. YellowSwordfish
    Member
    Posted 13 years ago #

    I am on shaky ground here as I know very little about MU. So I am not really sure what you mean by 'for all' or by 'main blog'. My understanding of this, from the users I have, is that they have a blog running on an MU hosted site. Does that make sense?

    And I use the $current_user object to identify the person currently accessing that blog (whether registered user or just un-registered visitor).

    Looking at it, the $current_user object appears to be set up the same as standard WP. But with standard WP I can access the object globally once I have included config.php into a code file that is not 'included' itself. With MU the object comes back unpopulated.

  4. YellowSwordfish
    Member
    Posted 13 years ago #

    I need to do some more tests but it looks like including wp-blog-header.php instead of config.php actually does the trick.

    Now I know that I have come across many statements that suggest you should use 'wp-blog-header.php' in standard WP but I have come across just as many that suggest it's not a good idea.

    Is there any reason why I shouldn't use it as it does what I need?

About this Topic

  • Started 13 years ago by YellowSwordfish
  • Latest reply from YellowSwordfish