Title: Hide restricted posts from queries
Last modified: September 2, 2021

---

# Hide restricted posts from queries

 *  Resolved [Jordi](https://wordpress.org/support/users/jordi1/)
 * (@jordi1)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/hide-restricted-posts-from-queries/)
 * Hi,
    Since UM version 2.2 their query strategy does not match our needs. We cannot
   use the “404 page” when restricting a post. Instead we need to redirect the user
   to the login page when he/she receives a newsletter with that restricted post.
 * I think this can be easily solved using pre_get_posts in functions.php. But I
   unknow where in WP data tables are stored the restrictictions (roles) to the 
   posts. I did not find any documentation about it and until now I did not find
   the arrays/elements by inspecting the WP database with phpMyAdmin.
    Thanks for
   any hint

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

 *  Thread Starter [Jordi](https://wordpress.org/support/users/jordi1/)
 * (@jordi1)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/hide-restricted-posts-from-queries/#post-14833639)
 * If this can help to any other user.
    I found the meta_key in postmeta WordPress
   table. Its name is um_content_restriction. Then the meta_value field stores the
   different roles I selected for every single post. For example: um_role1, um_role2,
   etc. (um_ is added by UM plugin to my name).
 * I need to strictly hide posts everywhere for which user has not the proper role.
   By now none of the sample codes I found over internet worked as required.
 * Any advise wil be welcome.
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/hide-restricted-posts-from-queries/#post-14834001)
 * Hi [@jordi1](https://wordpress.org/support/users/jordi1/)
 * Please see this pinned topic:
    [https://wordpress.org/support/topic/ultimate-member-2-2-0-404-page-for-restricted-posts-instead-redirect-or-message/](https://wordpress.org/support/topic/ultimate-member-2-2-0-404-page-for-restricted-posts-instead-redirect-or-message/)
 * Regards,
 *  Plugin Contributor [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * (@champsupertramp)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/hide-restricted-posts-from-queries/#post-14841954)
 * Hi [@jordi1](https://wordpress.org/support/users/jordi1/)
 * Please feel free to re-open this thread by changing the Topic Status to ‘Not 
   Resolved’ if any other questions come up and we’d be happy to help. 🙂
 * Regards,

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

The topic ‘Hide restricted posts from queries’ is closed to new replies.

 * ![](https://ps.w.org/ultimate-member/assets/icon-256x256.png?rev=3160947)
 * [Ultimate Member – User Profile, Registration, Login, Member Directory, Content Restriction & Membership Plugin](https://wordpress.org/plugins/ultimate-member/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ultimate-member/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ultimate-member/)
 * [Active Topics](https://wordpress.org/support/plugin/ultimate-member/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ultimate-member/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ultimate-member/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Champ Camba](https://wordpress.org/support/users/champsupertramp/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/hide-restricted-posts-from-queries/#post-14841954)
 * Status: resolved