logo

This is an old version of this answer!

Return to the current answer
In your page template (default page.php), you can add a list of user names as custom fields and check the current user against them.

To get the list of users (as custom fields), use get_post_meta()



To get the current user use:


$current_user = wp_get_current_user();
$id = $current_user->ID;
$user_name = $current_user->user_login;


For example:

$current_user = wp_get_current_user();
$users = get_post_meta(get_the_ID(), 'users', false);
$accepted = false;
if (is_array($users))
{
foreach ($users as $user)
{
if ($current_user->user_login == $user)
{
$accepted = true;
}
}
}

if (!$accepted)
{
// stop showing the page
}

Khanh Cao | 09/01/10 at 1:58pm

This is an old version of this answer!

Return to the current answer