37 responses to “Using shortcodes to show members-only content”

  1. Thomas Clausen

    This is brilliant Justin, thanks for sharing this.

    You write it’s for post and pages, but would it work for widgets as well?

  2. Ryan

    Great tutorial Justin. Thanks a bunch for all your contributions. Keep ‘em coming.

  3. Many

    I’ve really said it but surely shortcodes are lovely :D

  4. Nice
  5. The Frosty @WPCult

    Wow I can see how this could be useful.

  6. Dick

    This is GREAT, but will you write a followup on how to facilitate the user signup or point me to a good source for that? Thanks.

  7. Kevin

    I really like not having to depend on plugins. Thanks for posting this. I’m going to start using it right away.

  8. Kat

    Hi Justin,

    Love this info – thanks so much.

    Inferring that you’re not planning on doing a tutorial on the member-joining part of this process, can you suggest a resource for that code?

    Thanks again,

    - Kat

  9. Using WordPress as a members website « Logorrhea

    [...] shortcodes to show member only content. The great thing about this is that you can use shortcodes in any bog standard template. So you [...]

  10. Using shortcodes to show members-only content — WPCult

    [...] Looking to hide content to non members?By Austin on May 12, 2009 Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic.Are you looking for a better way to hide content to non-members? You may want to check this out: Using shortcodes to show members-only content [...]

  11. WordPress shortcode: Display content to registered users only- Pro Blog Tutorials

    [...] Justin Tadlock has another great tutorial for WordPress users, and it is how to hack/modify your WordPress template so that content on the site will only be available to registered users only. [...]

  12. bitkahuna

    Dick – I use sidebar login and register plus plugins to allow users to register as ’subscribers’ only. Works great.

    Justin, you da man!!!!

  13. 10 incredibly cool WordPress shortcodes
  14. Jason

    I must be putting the code in the functions.php in the wrong place? I got it to hide content, but when a user goes to login there is an error:
    Warning: Cannot modify header information – headers already sent by (output started at /home1/capeknin/public_html/capek9cardio/wp-content/themes/CoolWater/functions.php:32) in /home1/capeknin/public_html/capek9cardio/wp-login.php on line 287

    Warning: Cannot modify header information – headers already sent by (output started at /home1/capeknin/public_html/capek9cardio/wp-content/themes/CoolWater/functions.php:32) in /home1/capeknin/public_html/capek9cardio/wp-login.php on line 299

  15. Ditutu

    Great tutorial Justin , you are a great blogger . I’ve seen a lot of good posts wroted by you ,it’s impressive what you can do .

  16. WPSavetnik - Zaštita sadržaja lozinkom

    [...] elegantno je rešenje sa bloga Džastina Tedloka, koji koristi tzv. shortcodes da bi prikazao određeni sadržaj samo registrovanim posetiocima [...]

  17. Developing a user management plugin

    [...] Shortcodes Provides a set of shortcodes that may be used to restrict or provide access to certain areas of your site from within the post editor (like the shortcodes I posted in Using shortcodes to show members-only content). [...]

  18. Ralf Skirr

    Hi Justin,

    That’s an elegant solution, better than using plugins with huge overhead.

    Unfortunately I get the ‘Cannot modify header information’ error too.

    Any suggestion how to fix it?

    Thanks,
    Ralf

  19. Ralf Skirr

    Okay, I fixed the ‘Cannot modify header information’ error. For anybody who might have the same problem:

    Make sure there is no white space outside of the php start and end tags. While a blank line before the <?php start tag may look innocent, when processed by PHP, it will turn into an echo statement printing out a blank line. This is a common culprit.
    source:
    http://www.tech-recipes.com/rx/1489/solve-php-error-cannot-modify-header-information-headers-already-sent/

  20. WordPress tips, hacks and tutorials » Nice2All.com » Content for Logged-In Users Only

    [...] way of doing this. Fortunately I remembered an article that I read a few months back over at Justin Tadlock’s blog. I went hunting and found that the method used in Justin’s article was exactly what I was [...]

  21. Lynne

    The members only code snippet worked beautifully. Thanks.

  22. Lynne

    Interestingly if I use in a document, the members only code doesn’t work any more.

    Does anyone know if there’s a “fix” for this.

  23. Lynne

    Interestingly if I use “nextpage” in a document, the members only code doesn’t work any more.

    Does anyone know if there’s a “fix” for this.

    “Sorry for doubleposting, but the code for nextpage that I inserted didn’t show up.”

  24. CG

    i’d like to see this with a little button on the wysiwyg editor so that I can highlight my posts’s text that i want hidden… much like i would to bold some text etc.

  25. John

    Is there any way I can get this to work with post excerpts?

    Right now, if a post is within the [member] tags, nothing shows up in the excerpts. I’d like it to say something like “This post is viewable to members only”. Love the tip on the shortcodes!!

  26. Coafuri

    Hey, thanks for the code, I will just try this out.Definitely will be a great timesaver

  27. 10 Useful WordPress Coding Techniques « Smashing Magazine

    [...] Using shortcodes to show members-only content [...]

  28. Wordpress Blog Services - 10 Useful WordPress Coding Techniques

    [...] Using shortcodes to show members-only content [...]

  29. 10 Useful WordPress Coding Techniques « Tech7.Net

    [...] Using shortcodes to show members-only content [...]

  30. Web Design News » 10 Useful WordPress Coding Techniques

    [...] Using shortcodes to show members-only content [...]

  31. 22 Latest Exceptional WordPress Hacks | EzTips | Wordpress Tips - Tutorials - Make Money Online

    [...] Source Link [...]

  32. mariusz

    Fine, but if in content section you’d find a link to file?

    It would be accessfull for non-logged users if they knew the link to a file… how to solve that?

  33. Enhance Your WordPress Themes With Shortcodes | Devlounge

    [...] Justin Tadlock [...]

  34. Luis Lopez Garay

    That was just as usefull as I need. Some people needs to hide content to their guest visitors and this post is the solution I give to somebody who asks me that.

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.

Please use your real name or a pseudonym (e.g., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.