Posted By

howardpanton on 01/11/11


Tagged

wordpress shortcode


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

qubestream
meshwerk
anhonestboy


WordPress shortcode: Display content to registered users only


 / Published in: PHP
 

WordPress shortcode: Display content to registered users only

  1. Just paste the following code on your functions.php file:
  2. add_shortcode( 'member', 'member_check_shortcode' );
  3.  
  4. function member_check_shortcode( $atts, $content = null ) {
  5. if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
  6. return $content;
  7. return '';
  8. }
  9. Once done, you can add the following to your posts to create a portion or text (or any other content) that will be only displayed to registered users:
  10. [member]
  11. This text will be only displayed to registered users.
  12. [/member]

Report this snippet  

You need to login to post a comment.