{"id":1234,"date":"2013-06-07T16:11:10","date_gmt":"2013-06-07T07:11:10","guid":{"rendered":"http:\/\/www.santoshkori.com\/blog\/?p=1234"},"modified":"2013-06-07T16:41:16","modified_gmt":"2013-06-07T07:41:16","slug":"display-content-to-registered-users","status":"publish","type":"post","link":"https:\/\/www.santoshkori.com\/blog\/display-content-to-registered-users\/","title":{"rendered":"How to display content to registered users only"},"content":{"rendered":"<p>Ever wanted to be able to show some content only to registered users in your blog posts? If yes, just read this recipe, which contains an awesome shortcode to do it!<\/p>\n<p>here is code to\u00a0<a href=\"https:\/\/www.santoshkori.com\/blog\/wordpress\/display-content-to-registered-users\/\">\u00a0display content to registered users only<\/a><\/p>\n<p>Just paste the following code on your <em>functions.php<\/em> file:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nadd_shortcode( 'member', 'member_check_shortcode' );\r\n\r\nfunction member_check_shortcode( $atts, $content = null ) {\r\n\t if ( is_user_logged_in() &amp;amp;&amp;amp; !is_null( $content ) &amp;amp;&amp;amp; !is_feed() )\r\n\t\treturn $content;\r\n\treturn '';\r\n}\r\n<\/pre>\n<p>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:<\/p>\n<pre>\r\n[member]\r\nThis text will be only displayed to registered users.\r\n[\/member]\r\n<\/pre>\n<p>That&#8217;s all. Easy and useful!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever wanted to be able to show some content only to registered users in your blog posts? If yes, just read this recipe, which contains an awesome shortcode to do it! here is code to\u00a0\u00a0display content to registered users only Just paste the following code on your functions.php file: add_shortcode( &#8216;member&#8217;, &#8216;member_check_shortcode&#8217; ); function member_check_shortcode( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[600,598,601,599,597,602,606,605,604,603],"class_list":["post-1234","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-content-to-registered-users-only","tag-display-content-to-registered-users-only","tag-how-to-display-content-for-registered-users-only","tag-how-to-display-content-to-registered-users","tag-how-to-display-content-to-registered-users-only","tag-how-to-show-content-to-registered-users-only","tag-registered-users-only-show-content","tag-show-content","tag-show-content-to-registered-users","tag-show-content-to-registered-users-only"],"_links":{"self":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/comments?post=1234"}],"version-history":[{"count":4,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1234\/revisions"}],"predecessor-version":[{"id":1238,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1234\/revisions\/1238"}],"wp:attachment":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/media?parent=1234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/categories?post=1234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/tags?post=1234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}