Possible Duplicate:
determining if the user is logged in

Please check my site http://247ebookstore.com/sg3/monestatic-igues/ still working on it. If you check the given page you'll see "Visit Website" button there. I want that User must Logged In to view the website link. I don't know much coding so please anyone kindly tell me the code and place where to put it. Thanks.


2 Answers 2


You could give Private Only a shot - but it's best for you to do your own research on the Plugin Repository to find the plugin that suites your needs best.


You can wrap any content with:

<?php if( is_user_logged_in() ): ?>

Only for logged in users

<?php else: ?>

You need to login

<?php endif; ?>
  • I couldn't find that code. Could you please help me? Any logged in user can submit the listing so I don't know how this theme working in creating listing. Where to put this code?
    – user24272
    Nov 30, 2012 at 20:52
  • You need to add that code to the template that is creating the "View Website button". Wrap the if( is_user_logged_in() ) code around that button. Nov 30, 2012 at 20:53
  • Thanks developdaly, You made my day. I found the place its "_single.php" I've edited it and wrapped the codes as you instructed and it worked! 247ebookstore.com/sg5/directorypress
    – user24272
    Dec 2, 2012 at 12:51
  • Now what I want is, if user is paid member(Gold Member on my site) and if user has visited the site in 24 hours and if the sweepstakes is of category "one entry/day" then it shows "You have already entered for today" and if it is one time entry then it shows "Already Entered" so my Gold members don't get disqualified and this would be the main feature for members. If you can tell me code then I would be thankful.
    – user24272
    Dec 2, 2012 at 12:57
  • You should accept this answer as complete and open a new question ... this one was closed, so you'll get better responses with a new Q. Dec 2, 2012 at 16:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.