[wp-hackers] WP_Query filter posts by role

Mario Peshev mario at peshev.net
Wed Sep 5 23:53:42 UTC 2012


I think the initial idea is performance wise, MySQL is notorious with the
lack of ability of an adequate JOIN work so that's the reason everything in
WP to be persisted in a single table wherever possible. Extra JOIN
statements on a large blog with 6-7 digits of posts and hundred Ks users
would lead to dramatic results.

Which doesn't exclude the fact that in a real project with users this
generates problems.

Mario Peshev
Training and Consulting Services @ DevriX
http://www.linkedin.com/in/mpeshev
http://devrix.com
http://me.peshev.net




On Thu, Sep 6, 2012 at 1:28 AM, Kevinjohn Gallagher <
kevinjohngallagher at hotmail.com> wrote:

>
>
>
> I think this is a great example of where the 1 to 1 relationship of WP >
> User is not as flexible for today's market as it could be.The binary
> segmentation of Logged in / Logged out works for blogs, but as soon as you
> move away from that you start to hit issues.bbPress and buddyPress are
> great examples.
>
> Just my two cents.
>
> Kevinjohn Gallagher
> +44 (0) 7788 718382
> KevinjohnGallagher at hotmail.com
> http://www.kevinjohngallagher.com
> http://www.linkedin.com/in/kevinjohngallagher
>
>
>
>
> > From: jer at simianuprising.com
> > Date: Tue, 4 Sep 2012 13:21:36 -0400
> > To: wp-hackers at lists.automattic.com
> > Subject: Re: [wp-hackers] WP_Query filter posts by role
> >
> > On Mon, Aug 27, 2012 at 5:51 AM, Filippo Pisano <
> filippo.pisano at gmail.com>wrote:
> >
> > >
> > > is there a way to filter all posts written by users with specific roles
> > > (editors, authors etc)?
> > >
> > >
> > There is no WP_Query parameter that will do what you want, so your only
> > option is probably to use the posts_from and posts_where filters to add
> in
> > custom SQL.
> >
> > Users' roles are stored in the wp_usermeta table of the database as a
> > serialzed array of all their roles and/or individual capabilities. This
> > means you will almost definitely NOT want to access them directly.
> Instead
> > I propose that what you'd want to do is generate an array with all users
> in
> > a given role, then in the posts_where filter add a clause that fetches
> > posts from any of the authors from that array.
> >
> > Not a simple solution but your problem is fairly unique. User roles are
> > intended for use in controlling access permissions rather than for
> marking
> > content sections of your site (though your issue points out how such a
> > 'content groups' need often comes up).
> >
> > --
> > Jeremy Clarke
> > Code and Design • globalvoicesonline.org
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list