{"id":1074,"date":"2012-11-09T02:50:38","date_gmt":"2012-11-08T17:50:38","guid":{"rendered":"http:\/\/www.santoshkori.com\/blog\/?p=1074"},"modified":"2012-11-09T03:09:28","modified_gmt":"2012-11-08T18:09:28","slug":"how-to-define-access-on-specific-content-in-wordpress-for-a-specific-user-only","status":"publish","type":"post","link":"https:\/\/www.santoshkori.com\/blog\/how-to-define-access-on-specific-content-in-wordpress-for-a-specific-user-only\/","title":{"rendered":"How to define Access on specific content in WordPress for a specific user only"},"content":{"rendered":"<p>Some requirement comes to\u00a0access\u00a0specific portion of <a href=\"https:\/\/www.santoshkori.com\/blog\/tag\/wordpress\/\">wordpress<\/a> website to\u00a0specific\u00a0user only. So here is the code\u00a0define Access on specific content in <a href=\"https:\/\/www.santoshkori.com\/blog\/tag\/wordpress\/\">WordPress<\/a> for a specific user only.<\/p>\n<p>Update this code into Your template page like page.php, singlepost.php or wherever u want to do this.<!--more--><\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\n&lt;?php if(is_user_logged_in()):\r\nwp_get_current_user(); if ( (8 == $current_user-&gt;ID) || (1 == $current_user-&gt;ID) || (7 == $current_user-&gt;ID) ) { ?&gt;\r\n\r\n\/\/\/ Write your php code or function which you want to execute here if User who having ID 8,1,7 to see this area.\r\n\r\necho 'Content for Users ID = 1,7,8';\r\n\r\n&lt;?php } else {\r\n\/\/ Else Part Where Other LoggedIn Users which having ID 1,7,8 will see this area.\r\n\r\necho 'Content for Otherthan User ID = 1,7,8';\r\n}\r\nelse:\r\n\/\/\/ Else Area to Put php funtion or code to saw theme who is not logged into Your wordpress website.\r\n\r\necho 'Who are not logged in';\r\nendif; ?&gt;\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Some requirement comes to\u00a0access\u00a0specific portion of wordpress website to\u00a0specific\u00a0user only. So here is the code\u00a0define Access on specific content in WordPress for a specific user only. Update this code into Your template page like page.php, singlepost.php or wherever u want to do this.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[508,507,725],"class_list":["post-1074","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-define-access-on-specific-content-in-wordpress-for-a-specific-user-only","tag-how-to-define-access-on-specific-content-in-wordpress-for-a-specific-user-only","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1074","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=1074"}],"version-history":[{"count":4,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1074\/revisions"}],"predecessor-version":[{"id":1077,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/posts\/1074\/revisions\/1077"}],"wp:attachment":[{"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/media?parent=1074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/categories?post=1074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.santoshkori.com\/blog\/wp-json\/wp\/v2\/tags?post=1074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}