Support » Fixing WordPress » User level categories

  • Hello, I am using this ClasiPress to create a different type of listing classifieds.

    I will select manually who can subscribe or not (only a type of leaders for a religious institution).

    I have 4 categories. 2 of them need to be available to every one at all times (to browse). The 4 will be available to the leaders. The leaders will be able to post in all 4 Categories, and they will be able to view / post all 4 Categories. BUT the main public will only see two. How could I go about it?

    Thanks,

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter CreativeWP

    (@mevaser)

    I could make the two categories that need login, subjected to a php conditional line.

    I saw a solution similar ( How to block a category from one user and enable the category for the rest of the users – http://wordpress.stackexchange.com/questions/21558/how-to-block-a-category-from-one-user-and-enable-the-category-for-the-rest-of-the ), but I do not have the same problem.

    Basically, every one without login is able to see two of the four categories, two always hidden for every one, except teacher, who once login are able to see everything.

    Any one?

    Thread Starter CreativeWP

    (@mevaser)

    I should use something like this I do imagine:

    <?php if ( is_user_logged_in() ) { ... } ?>

    Yes that is correct:

    <?php if ( is_user_logged_in() ) { ?>
      <!-- code here for what only logged in users can see -->
    <?php } else { ?>
      <-- code here for what users that are not logged in see e.g. a login form -->
      <?php wp_login_form(); ?>
    <?php } ?>
    Thread Starter CreativeWP

    (@mevaser)

    Would this work? Where do I past it?

    <?php if ( (!is_user_logged_in()) && in_category('10,5')  ) { ?>
    You'll need to be a member to view this content.
    <?php } else { ?>
    <?php the_content(); ?>
    <?php } ?>
    Thread Starter CreativeWP

    (@mevaser)

    Ah, the categories are 10 and 5

    Where to past it depends on your theme but I would go for category.php.

    I would do this:

    <?php if(in_category( array( 5,10 ) ) { // if the current post is in categories 5 or 10 ?>
        <?php if ( !is_user_logged_in() ) { // check whether the user is logged in ?>
           <p>You'll need to be a member to view this content.</p>
       <?php } else { // user is logged in so go ahead and show content ?>
          <?php the_content(); ?>
      <?php } ?>
    <?php } ?>
    Thread Starter CreativeWP

    (@mevaser)

    My theme does not have Category.php…. hmm.

    Thanks,

    If it has an archive.php then do it in there, if not then index.php.

    Thread Starter CreativeWP

    (@mevaser)

    I was told the code sniped that I am using should work with this format:

    <?php global $current_user; get_currentuserinfo(); if ($current_user->user_level == 10 ) { ?>
    <a href="<?php echo CP_ADD_NEW_URL ?>" class="obtn btn_orange"><?php _e('Post an Ad', 'appthemes') ?></a>
    <?php } else { ?>
    <?php } ?>

    So, I have to make it work between this two code snip.

    <?php if(in_category( array( 5,10 ) ) { // if the current post is in categories 5 or 10 ?>
        <?php if ( !is_user_logged_in() ) { // check whether the user is logged in ?>
           <p>You'll need to be a member to view this content.</p>
       <?php } else { // user is logged in so go ahead and show content ?>
          <?php the_content(); ?>
      <?php } ?>
    <?php } ?>

    Can any one help me?

    Thanks,

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘User level categories’ is closed to new replies.