Title: check restriction from theme hook
Last modified: November 13, 2023

---

# check restriction from theme hook

 *  Resolved [ngvtech](https://wordpress.org/support/users/ngvtech/)
 * (@ngvtech)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/check-restriction-from-theme-hook/)
 * I created a hook in a theme which starts a query screen on a database. I would
   like to restrict the functionality to logged in users. How do I do this as apparently
   tags are not processed. Which functions should I use to check the login status/
   roles? Could somebody point me to the right functions in the manuals?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fcheck-restriction-from-theme-hook%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Georgian Cocora](https://wordpress.org/support/users/raster02/)
 * (@raster02)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/check-restriction-from-theme-hook/#post-17200236)
 * Hello [@ngvtech](https://wordpress.org/support/users/ngvtech/),
 * The logged in status of the user can be checked using a core function: [https://developer.wordpress.org/reference/functions/is_user_logged_in/](https://developer.wordpress.org/reference/functions/is_user_logged_in/)
 * If you need to check the user roles that the current user has you can grab the
   user object using a core function: [https://developer.wordpress.org/reference/functions/wp_get_current_user/](https://developer.wordpress.org/reference/functions/wp_get_current_user/)
   then look at the `roles` key from that object.
 * If you are on a post, page or custom post type and you have applied content restriction
   settings from Profile Builder to it, you can check if the content is restricted
   or not using a function from Profile Builder: **wppb_content_restriction_is_post_restricted**()
 * It returns true or false based on the restriction settings and current user. 
   The $post_id to check can also be passed to the function as a parameter.
 * Hope this helps!
 * Regards.
 *  Thread Starter [ngvtech](https://wordpress.org/support/users/ngvtech/)
 * (@ngvtech)
 * [2 years, 7 months ago](https://wordpress.org/support/topic/check-restriction-from-theme-hook/#post-17200567)
 * Yes, that helped. Thanks!

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

The topic ‘check restriction from theme hook’ is closed to new replies.

 * ![](https://ps.w.org/profile-builder/assets/icon-256x256.png?rev=2961144)
 * [User Profile Builder - Beautiful User Registration Forms, User Profiles & User Role Editor](https://wordpress.org/plugins/profile-builder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/profile-builder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/profile-builder/)
 * [Active Topics](https://wordpress.org/support/plugin/profile-builder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/profile-builder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/profile-builder/reviews/)

## Tags

 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [restrict](https://wordpress.org/support/topic-tag/restrict/)

 * 2 replies
 * 2 participants
 * Last reply from: [ngvtech](https://wordpress.org/support/users/ngvtech/)
 * Last activity: [2 years, 7 months ago](https://wordpress.org/support/topic/check-restriction-from-theme-hook/#post-17200567)
 * Status: resolved