hide block on dashboard conditionally

Discussion in 'Troubleshooting' started by dale_s, Jan 12, 2018.

Thread Status:
Not open for further replies.
  1. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    I have a third party aMember script which inserts a block into aMember dashboard.

    Plugin works great, but need to hide all block stuff (header, box, etc) if a user doesn't have a specific product.

    This way, the block only shows for users who have the product. I'm guessing hiding blocks with the existing css classes is the easiest method.

    Maybe a function similar to this will work in site.php

    Code:
    $user = Am_Di::getInstance()->user;
    if ( in_array(5, $user->getActiveProductIds()) ) { 
    But, I can't figure out the rest. I tried to contact the plugin author but I can't seem to reach them.

    I have these two div ids:

    #cert-download-head
    #cert-download

    Anyone have a suggestion on how to hide these, unless user has a specific product?

    Thanks for any help.
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Hello,

    The best option is add block conditionally actually.

    but in case of it is not possible to do by any reason then
    you can hide this block from PHP in site.php file.
    http://www.amember.com/docs/Site.php_file

    Here is example of code snippet to do it:
    PHP:
    if ($user Am_Di::getInstance()->auth->getUser()) {
        if (!
    in_array(5$user->getActiveProductIds())) {
            
    Am_Di::getInstance()->blocks->remove('cert-download');
        }
    }
    Best Regards.
  3. dale_s

    dale_s aMember Pro Customer

    Joined:
    Apr 12, 2013
    Messages:
    96
    Thank you very much!
    caesar likes this.
Thread Status:
Not open for further replies.

Share This Page