Home Forums General Issues Creating a \"Private\" area


Creating a \"Private\" area

  • Hi,
    I want to create a “Private” area inside a Website. I don’t want to use the WordPress “Private Post/Page” Function for some reasons. So I created a custom post type like “Private Pages”. I also created a template for this custom post type (“single-privatepages.php”). In the header of this template I check if the current user has set an ACF option (true/false) like:

    $user = new WP_User(get_current_user_id());
        $showintern = get_field('user_show-hidden_yes', 'user_'.$user->ID);
        if($showintern == 1) :
        // show hidden content

    This works. What do you think – is this a good/secure method to hide private pages? I am a little unsure …. .

  • Looks secure enough to me.

    Is the entire page supposed to be secure or just a portion of the content. At any rate, if you’re not outputting the content then there isn’t any way for the person to see it. If the person is not supposed to access the page at all I would probably redirect them to a different page. Also, you can probably just use get_current_user_id() would save you a line of code.

  • Thanks John! Only the content area is secured. Header and footer is the same as the rest of the site (which is public). Yeah i think this is a save solution 🙂 . ACF is so great … .

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Creating a \"Private\" area’ is closed to new replies.