Title: PHP snippets
Last modified: May 10, 2017

---

# PHP snippets

 *  [Rob](https://wordpress.org/support/users/robwyndrydercom/)
 * (@robwyndrydercom)
 * [9 years ago](https://wordpress.org/support/topic/php-snippets/)
 * I’m hoping this is the right community to ask this question. If not, please advise.
 * 2 questions about PHP:
    - Is there a WordPress PHP Library with proven PHP snippets?
    - I’m trying to make a site private for all but registered users. The plugins
      I have tried seem to create conflicts with other plugins, especially with 
      media for some odd reason. This seems like such a basic and tried need and
      at the risk of oversimplification I would think that all that needs to be 
      done in a plugin or PHP snippet is to see if the person accessing any page
      on a site is a registered user. If they are not, throw them to the login page.
      If they are, then onwards to the page on the site they want to go to. Isn’t
      there a PHP snippet out there that would do this perceived easy task?
 * Rob->

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

 *  [strub](https://wordpress.org/support/users/strub/)
 * (@strub)
 * [9 years ago](https://wordpress.org/support/topic/php-snippets/#post-9117662)
 * Makink things private is anyway not that easy with WP, especially for the media.
 * If one knows the url of the media, he can access it anyway.
 * Best would be to store things in the webroot, outside of public access. Then 
   a php script checks vor valid user rights before sending it to the user.
 *  Thread Starter [Rob](https://wordpress.org/support/users/robwyndrydercom/)
 * (@robwyndrydercom)
 * [9 years ago](https://wordpress.org/support/topic/php-snippets/#post-9117682)
 * I’m not so concerned about media, which for us is only photos. I just want to
   lock out anyone who is not a registered user as pages, tabs, accordions, etc.
   have very private information.
 *  Thread Starter [Rob](https://wordpress.org/support/users/robwyndrydercom/)
 * (@robwyndrydercom)
 * [9 years ago](https://wordpress.org/support/topic/php-snippets/#post-9117700)
 * But to my earlier point, even media would be protected with my simplified outlook
   of seeing if the person visiting a page or anything else in the site’s path is
   validated as a user or thrown out.
 * Is my concept of how to do this an oversimplification? Seems to me that if you
   are catching “https:[site]…..” and then validating if the user is registered,
   you have completely protected the site. Is there something that invalidates the
   thought?
 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [9 years ago](https://wordpress.org/support/topic/php-snippets/#post-9121937)
 * Hey [@robwyndrydercom](https://wordpress.org/support/users/robwyndrydercom/)
 * Not sure if it would help or if you have tried but one that came to mind while
   reading was the Restrict Content plugin: [https://wordpress.org/plugins/restrict-content/](https://wordpress.org/plugins/restrict-content/)
 *  Thread Starter [Rob](https://wordpress.org/support/users/robwyndrydercom/)
 * (@robwyndrydercom)
 * [9 years ago](https://wordpress.org/support/topic/php-snippets/#post-9122065)
 * Thanks Jose! I just installed My Private Site and that seems to be doing the 
   trick without interfering in anything else. Should that ultimately prove to not
   work, I will give this a try. Many thanks!
 *  Moderator [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * (@jcastaneda)
 * THEME COFFEE MONKEY
 * [9 years ago](https://wordpress.org/support/topic/php-snippets/#post-9122226)
 * That’s great to hear!
 * Be sure to mark the topic as resolved once it is 😉

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

The topic ‘PHP snippets’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 6 replies
 * 3 participants
 * Last reply from: [Jose Castaneda](https://wordpress.org/support/users/jcastaneda/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/php-snippets/#post-9122226)
 * Status: not a support question

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
