WordPress.org

Support

Support » Multisite » WP_User_Query and Multisite

WP_User_Query and Multisite

  • I am trying to get all users. All users were created in Network Admin. Some have been granted super admin privileges. The others are, according to the quote below, automatically subscribers. There are no role options offered in Network Admin.

    Using WP_User_Query I can only seem to get the super admins.

    And this yields no one:
    new WP_User_Query( array( 'role' => 'subscriber' ) )

    What gives? How do I get all users created in Network Admin?

    User Access: By design, all users who are added to your network will have subscriber access to all sites on your network. To allocate a different default role for users on individual sites, you must use a plugin, such as Multisite User Management.
    http://codex.wordpress.org/Create_A_Network

Viewing 15 replies - 1 through 15 (of 24 total)
  • They’re psudeo subscribers. For most sites, they have the same access as a logged-out user, and they don’t show up on the user lists.

    Where are you trying to get all users?

    The network admin -> Users lists has ’em all.

    I want to display all users on the front end, as a company’s employee directory. How can I do that using the users created in network admin? How to call all users even if they are pseudo users with pseudo roles?

    Not easily. They don’t exist as a part of any blog, so they aren’t listed in an easily accessible way.

    Can you add them all to the main site as subscribers for REAL and use that?

    I COULD, but that would be a semantically sad use of the multisite framework. The users (employees) are all part of the multisite (company), with different permissions per individual site (department).

    These users and their attributes exist in the database. As such, shouldn’t I be able to query for them?

    Yes, but it’s a DB query since the WP functinos are per-site.

    Wouldn’t everyone be a member of the main (company) site though? I mean I’m assuming you have this:

    domain.com – Main site. my cool company

    domain.com/hr – HR’s site

    domain.com/mail – the mailroom guys

    etc etc.

    Hmph… I suppose so… but it still doesn’t seem quite right…

    WP_User_Query( array( ‘blog_id’ => 1 ) )

    I guess I don’t see why creating (pseudo) users in network admin is even offered as an option then…

    Huh, wait… I, super admin, can create them in network admin, whereupon they will get an email to login to their profile, which they can fill in. Then I can check it and correct it before assigning them as a subscriber to the main site, whereupon they will be listed in the directory…

    I wonder if there’s a way that I, super admin, can get an email when a (pseudo) user or (real) user changes their profile?

    You can use a plugin to auto-add all new users to the main site.

    http://wordpress.org/extend/plugins/multisite-user-management/

    Hmmmmm. Since we are now blog-specific… why not use the “author” functionality: wp_list_authors() and author.php for the author (employee) detail page?

    It seems “author” = “user” if including the argument hide_empty=0 (show users even if they haven’t posted anything)

    Wouldn’t this be more efficient?

    I have a sneeking memory that author == user with at least a post. I could be wrong. It’s been a while.

    There’s a pay-for plugin called Members Directory which touts that it can do it, but it’s behind a paywall.

    Unless my back is up against the wall, I try to forgo plugins, free or paid. (Apparently, I like reinventing the wheel.)

    But author does = user if you set hide_empty (has no posts) to false. At least it did in my limited test.

    Aaaaaah! That would do it. 😀

    I’m pro plugin but anti-paywall. I fork a lot of plugins for what I need. 🙂

    Wish I knew how to fork!

    Meanwhile it’s time to throw roleless users vs postless authors into the ring to see who comes up fighting…

    Fork: Take someone else’s plugin. Make edits. Change the plugin name and version number so their updates don’t whack yours. Have a beer!

    I understood step 4 anyway… Will start there.

    I’m trying to figure out the same thing and it is utterly ridiculous that this should require complicated custom coding or plugins.

    Automattic apparently developed multisite for the WordPress.com use case; a network of blogs that are completely independent of eachother. That use case would make sense for maybe a big hosting company.

    Normal people in the real world will almost never use multisite that way. Most will try to use WP multisite as a network for an organization or company, only to find out the hard way that letting “users” interact on the platform is virtually impossible.

    Yes, being forced to add all users to the main blog is “a semantically sad use of the multisite framework”. In my case the main blog is used for organization news and announcement, so it’s the last place I want to have overrun by members/”users”.

    So we’re supposed to use half-baked plugins and hacks to fix the mess again.

    Can anyone give a basic example of a custom query to list all users in the ‘users’ database table?

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘WP_User_Query and Multisite’ is closed to new replies.