Results 1 to 4 of 4

Thread: Price visible only to a logged in member of a particular group. [SOLVED]

  1. #1

    Default Price visible only to a logged in member of a particular group. [SOLVED]

    Members of some group may see the price only after a login. How can I set up this restriction.

    With code below, I can hide price in general if some one is not logged in. But there is no group restriction.
    Code:
    <?php if (FE_USER_LOGGED_IN) : ?>
        show price
    <?php else: ?>
       hide price
    <?php endif; ?>
    Last edited by tsarma; 12/28/2015 at 12:07.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  2. #2
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    402

    Default

    PHP Code:
    <?php
      $member 
    = \FrontendUser::getInstance();

      echo 
    '<pre>';
      
    var_dump(
        
    $member->username,
        
    $member->firstname,
        
    $member->isMemberOf(3)
      );
      echo 
    '</pre>';
    ?>
    https://github.com/contao/core/blob/.../User.php#L651
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  3. #3

    Default

    Hi Andreas,

    That was a useful tips.

    I've defined a new $GLOBALS['ISO_HOOKS']['generateProduct'] and with that I've added a new template variable (previleged). Thus I can use

    Code:
    <?php if ($this->previleged) : ?>
        show price
    <?php else: ?>
       hide price
    <?php endif; ?>
    Thanks a lot
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  4. #4
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    402

    Default

    Glad I could help
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

Bookmarks

Posting Permissions

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