Posted By

themolitor on 06/17/10


Tagged

wordpress


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

BrianCoyDesign
d55beck
mikoli
laurentzziu


WordPress: Member Only Content


 / Published in: PHP
 

  1. //FUNCTION.PHP
  2. function member_check_shortcode($atts, $content = null) {
  3. if (is_user_logged_in() && !is_null($content) && !is_feed()) {
  4. return $content;
  5. } else {
  6. return 'Sorry, this part is only available to our members. Click here to become a member!';
  7. }
  8.  
  9. add_shortcode('member', 'member_check_shortcode');
  10.  
  11. //add the following to your posts to create a section or text (or any other content) that will be displayed only to registered users:
  12.  
  13. [member]
  14. This text will be displayed only to registered users.
  15. [/member]

Report this snippet  

You need to login to post a comment.