Posted By

juanfer on 11/09/11


Tagged

login php wordpress wp user shortcode guest


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

Kurt
jbreitenbucher
srdjan


[Wordpress shortcode] Show content for logged in users


 / Published in: PHP
 

Usage:

[hide]Hide content for guest[/hide]

*Doesn't work on comments!

add this into your function.php template file

  1. <?php
  2. add_shortcode("hide","hide_shortcode");
  3.  
  4. function hide_shortcode($x,$text=null){
  5. if(!is_user_logged_in()){
  6. return "You have to been registered and logged in to see this content";
  7. }else{
  8. return do_shortcode($text);
  9. }
  10. }
  11. ?>

Report this snippet  

You need to login to post a comment.