Skip Navigation

[Closed] Filter posts matching the current user with a custom field value

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 11 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Tagged: 

This topic contains 1 reply, has 1 voice.

Last updated by Yanes Arroyo 11 years, 10 months ago.

Author
Posts
#11667

Hi!

We are trying to build a query using the Views filters based on a result from a custom field. Basically, we've used an outside set of functions (check it out here: hidden link) to print a set of custom fields, which does this: A) loads all "subscriber" users into a radio group list, and B) allows the author to assign the post to one of them.

So far, so good: We can see our custom field (lets call it

$custom_user

) when we start building our query using the filter editor on Views, and we can even print it on the template area. So, if we have previously selected the username "greenperson" through our custom field, then i can print "greenperson" inside the template of the post assigned to that user. That means that the value of that custom field it's working fine, but what we need to do is this:

1. Get the current logged in user: we could do this using

wp_get_current_user()

, e.g.: we could assign it to a

$current_user

variable (in fact, we are already doing that in our functions.php file).
2. Then, if

$custom_user = $current_user

: give me the posts that match that criteria.

So, to be brief: using the query builder filters, how can I ask for

wp_get_current_user()

and then compare it with the result of a custom field?

Any suggestions?

Thanks in advance!

PS: and BTW, Views and Types are one of the most awesome plugins we have ever used. Thank you so much for creating this! I'm not posting this on the Paid users support Forum because my partner, how is the person who bought Views, is not here right now and I can't access using his account.

#11687

I've managed to get my partner credentials and posted again this thread on the paid support forum. If you have any suggestions, please leave it there! https://toolset.com/forums/topic/filter-posts-matching-the-current-user-with-a-custom-field-value-2/

The topic ‘[Closed] Filter posts matching the current user with a custom field value’ is closed to new replies.