Title: Adding Restrict Code in php
Last modified: September 1, 2016

---

# Adding Restrict Code in php

 *  Resolved [beppe65](https://wordpress.org/support/users/beppe65/)
 * (@beppe65)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/adding-restrict-code-in-php/)
 * Is it possible adding a code directly in php template pages (i.e. single.php),
   to protect a certain part of it? I need to protect some custom fields added in
   this page. Thanks
 * [https://wordpress.org/plugins/restrict-content/](https://wordpress.org/plugins/restrict-content/)

Viewing 1 replies (of 1 total)

 *  Moderator [Pippin Williamson](https://wordpress.org/support/users/mordauk/)
 * (@mordauk)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/adding-restrict-code-in-php/#post-7525051)
 * Yes, just use the `is_user_logged_in()` function: [https://developer.wordpress.org/reference/functions/is_user_logged_in/](https://developer.wordpress.org/reference/functions/is_user_logged_in/)

Viewing 1 replies (of 1 total)

The topic ‘Adding Restrict Code in php’ is closed to new replies.

 * ![](https://ps.w.org/restrict-content/assets/icon.svg?rev=3529325)
 * [Membership Plugin - Kadence Memberships](https://wordpress.org/plugins/restrict-content/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/restrict-content/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/restrict-content/)
 * [Active Topics](https://wordpress.org/support/plugin/restrict-content/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/restrict-content/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/restrict-content/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Pippin Williamson](https://wordpress.org/support/users/mordauk/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/adding-restrict-code-in-php/#post-7525051)
 * Status: resolved