+ Reply to Thread
Results 1 to 3 of 3

Thread: Protecting comments for different levels of user?

  1. #1

    Question Protecting comments for different levels of user?

    Hi there, I'm working on a product that will have a gold/silver level. Gold/silver users will all see the same pages, but gold users can comment on lesson pages, silver users can not. Is there a way to modify a theme page so that if a gold user is viewing, they can see comments, but comments don't get loaded for silver users?

    I know I could duplicate ALL the pages and just turn off commenting on those pages gold can see and silver can not, but modifying the theme would be a lot simpler, particularly when it came time to updating course material, etc.

    Cheers,
    Daisy

  2. #2

    Talking Re: Protecting comments for different levels of user?

    I'm going to reply to this myself in case others want to see the solution (or in case I need to find the solution again myself). Veena provided this solution, and it WORKED, and she rocks

    In the theme template file for the pages in question where comments are to appear or not appear (in my case, page.php in my theme folder), I replaced the code like so:

    Code:
    replace this:
    <php comments_template() ?>
    
    with this:
    
        <?php
    
    include_once "/dap/dap-config.php"; 
    
    if( Dap_Session::isLoggedIn() ) { 
    	$session = Dap_Session::getSession(); //get userid
    	$user = $session->getUser();
    	$user = Dap_User::loadUserById($user->getId()); //reload User object
    	if(isset($user)) {
    		$productId = 2; // DAP Product Id
    		$hasAccess = $user->hasAccessTo($productId);
    		if($hasAccess) {
    			comments_template();//user has access to dap product Id = 1
    		}
    
    	}
    }
    
    ?>
    Again, huge thank you to Veena for providing this as a solution!!

    Cheers,
    Daisy

  3. #3

    Re: Protecting comments for different levels of user?

    So I tweaked this further, because I have two products that can see the comments and the rest cannot. Gold and Pilot groups can see the products:
    PHP Code:
    include_once "/dap/dap-config.php"

    if( 
    Dap_Session::isLoggedIn() ) { 
        
    $session Dap_Session::getSession(); //get userid
        
    $user $session->getUser();
        
    $user Dap_User::loadUserById($user->getId()); //reload User object
        
    if(isset($user)) {
            
    $productIdPilot 2;     // DAP Product Id
            
    $productIdGold 3;
            
    $hasAccess $user->hasAccessTo($productIdPilot) || $user->hasAccessTo($productIdGold);
            if(
    $hasAccess) {
                
    comments_template();//user has access to dap product Id = 2 or 3
            
    }

        }


+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts