Title: Filter based on user
Last modified: April 30, 2019

---

# Filter based on user

 *  Resolved [Mosche](https://wordpress.org/support/users/mosche/)
 * (@mosche)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/filter-based-on-user/)
 * Dear Support,
 * I’m trying to filter an output of a custom post type, where the output is filtered
   based on the current user’s display name.
    [loop type=custom-post-type field=
   custom-field value=’user-name’] [field custom-field] [field custom-field1] [field
   custom-field2] [field custom-field3] [/loop]
 * The custom-field is the same value as the user’s display name.
    How can I dynamically
   input the user display name as the value to be filtered. Or is there a different
   way I could filter custom posts based on the user viewing the page. Please advise.
 * Regards,
 * Mosche

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Peter Berger](https://wordpress.org/support/users/peterpolow/)
 * (@peterpolow)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/filter-based-on-user/#post-11483176)
 * Hi,
 * I’m not sure I’m following you…
 * Do you want to display the posts of the current user? Then you can user this 
   code…
 *     ```
       [loop type=custom-post-type author=this]
       	[field title]
       	[field custom-field]
       	[field custom-field1]
       	[field custom-field2]
       	[field custom-field3]
       [/loop]
       ```
   
 * Or is the name of the user in the custom field another user then the author of
   the post?
 * This code will display the post where the value in the custom field is equal 
   to the display name (selected in the combo box of the user profile) of the user
   who is logged in.
 *     ```
       [pass user_field=fullname]
       [loop type=custom-post-type field=name-of-the-field value='{USER_FIELD}']
       	[field title]
       	[field custom-field]
       	[field custom-field1]
       	[field custom-field2]
       	[field custom-field3]
       [/loop] 
       [/pass]
       ```
   
 * Keep in mind that the user can change his own display name, then it will not 
   match the custom field anymore. Using the username for this is more solid…
 * Peter
 * By the way: I’m not “Support”, but just a all day user of this excellent plugin.
    -  This reply was modified 7 years, 1 month ago by [Peter Berger](https://wordpress.org/support/users/peterpolow/).
 *  Thread Starter [Mosche](https://wordpress.org/support/users/mosche/)
 * (@mosche)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/filter-based-on-user/#post-11483678)
 * Hi Peter,
 * First of all, thank you! The second one is the one I was looking for and it works
   like a charm. And especially thanks for the speed of the support.
    Secondly, 
   that is an excellent solution. I was not aware of the [pass] option. Thirdly,
   after your clarification I realized I meant the login name. The one that cannot
   be changed. The display name can be changed, so I’m better off using the login
   name instead. Since there is no guarantee that the user might accidentally change
   that. I used the code and substituted “fullname” with “name” in the first line
   and it works like a charm. Fourthly, this is an awesome plugin.
 * Regards,
 * Mosche

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Filter based on user’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Mosche](https://wordpress.org/support/users/mosche/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/filter-based-on-user/#post-11483678)
 * Status: resolved