Home » Wordpress » How to define Access on specific content in WordPress for a specific user only

Some requirement comes to access specific portion of wordpress website to specific user only. So here is the code define 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.


<?php if(is_user_logged_in()):
wp_get_current_user(); if ( (8 == $current_user->ID) || (1 == $current_user->ID) || (7 == $current_user->ID) ) { ?>

/// Write your php code or function which you want to execute here if User who having ID 8,1,7 to see this area.

echo 'Content for Users ID = 1,7,8';

<?php } else {
// Else Part Where Other LoggedIn Users which having ID 1,7,8 will see this area.

echo 'Content for Otherthan User ID = 1,7,8';
}
else:
/// Else Area to Put php funtion or code to saw theme who is not logged into Your wordpress website.

echo 'Who are not logged in';
endif; ?>

Incoming search terms:

Leave a comment

0 Comments.

Leave a Reply


[ Ctrl + Enter ]

*

Wordpress Freelancer, Joomla Freelancer Web designer Mumbai india, Wordpress web developer India, Joomla Web developer india, Outsourcing web project india mumbai

By Santosh Kori Published: October 10, 2012 Professional Freelance Website developer 5 stars based on 65 reviews Total time: 24 hour 00 min Wordpress Joomla XHTML CSS jQuery HTML5 eCommerce CSS3 ☞ Offers low cost freelance web designing, asp php asp.net web development services from Mumbai India. Freelance web designer & developer Mumbai India.

I AM NOT AVAILABLE FOR WEB DESIGN & DEVELOPMENT PROJECTS