• Resolved enigmaticfox

    (@enigmaticfox)


    Hey there! For a very customized theme a while back, I was required to create a navigation which only listed out users with the role of “Author” assigned to them. The basic concept was that the blog is at a school, and certain students will be blogging about their school experiences, so they’re being signed up with the Author role. When they sign up, I’ve got extra meta fields in there to capture information like their hometown, interests, etc, and those are listed out in the navigation that gets generated from the query.

    The only way I could figure out to do this was to write a specific SQL query, which worked fine on my local single site:

    $myauthors = $wpdb->get_results( "SELECT * from $wpdb->usermeta WHERE meta_value like '%:\"author\";%'" );

    However, this theme has been set up on a site that resides within a multisite setup. So now, that query is returning the metadata of every user across the multisite with a role of Author, not just the ones within our blog! Definitely a problem.

    I’ve been trying to research the newer Multisite database setup, to see how I could do this, but I’ll admit that my SQL skills are pretty rusty. And I have no experience at all with multisite setups.

    Any advice from folks here as to how one could limit the search to return only the metadata of authors on my particular blog? Any help would be much appreciated!

    Take care,

    –Sherri

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘SQL search for users with the Author role on a single site within a multisite?’ is closed to new replies.