A nice example on WpRecipes shows how to tag a piece of content in a post to be shown only to logged in users. This shows how shortcode is used, and could be used as a model to create your own little snippets of functionality that could be used in posts. A little less weighty than creating a full plugin, and a good way to get started with WordPress programming.
WordPress shortcode: Display content to registered users only
add_shortcode( ‘member’, ‘member_check_shortcode’ ); function member_check_shortcode( $atts, $content = null ) { if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) return $content; return ”; }
ADD YOUR COMMENT
Comments are moderated.
Randall Rode's online home for thoughts, notes, and experiments with a wide range of technology topics. Visit the about page for info on my recent projects and professional background. I welcome your comments!
New articles are normally posted on Mondays and Wednesdays. Subscribe to the RSS feed or the email update to keep current on the latest posts.