Forum

Thread tagged as: Question, Configuration, Blog

Can you make a blog section hidden for members?

Is this possible to do. Any pointers.

David Owen

David Owen 0 points

  • 5 years ago
Simon Clay

Simon Clay 127 points

Hi David, I would wrap the blog page code to check they're logged in, otherwise display the login form:


<?php if (perch_member_logged_in()) { Blog code here } else { perch_members_login_form(); } ?>

And to hide 'Blog' from the main nav to those who aren't members, tick 'Hide from main navigation' in 'Page Options' then to call the nav on the page:


<?php if (perch_member_logged_in()) { perch_pages_navigation(array( 'include-hidden' => true, )); } else { perch_pages_navigation(); } ?>

Thanks Simon...

The client would like to have some blog posts public but some available to only logged in members.

So I was thinking to use blog sections. And have a section called "members" only viewable if logged in. Do you think that is possible.

Simon Clay

Simon Clay 127 points

Hi David, I'm sure that's possible. You'd show the section only if the member was logged in:

<?php 
  if (perch_member_logged_in()) {
    perch_blog_section(perch_get('members')); 
  }
?>

Thanks.