How To Hide Additional Field If No Active Subscription?

Discussion in 'Customization & add-ons' started by kinitex, Sep 25, 2012.

  1. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    I added a new field called accountnumber, and I added it to the profile page. I only want it to show to users that have an active subscription though, how do I do this?
  2. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    No way out of the box.
    Would be good to have an option to allow display if active in X membership- will put the request in the tracker.

    David
  3. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    I used to use this in an old version of amember in the profile.html template file that worked perfectly...

    HTML:
    {if $smarty.session._amember_products}
    {$additional_fields_html}
    {else}
    <tr>
        <th>Account Number</th>
        <td>You must have an active subscription to use this feature!</td>
    </tr>
    {/if}
  4. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    PHP:
    if ($member_products)
    This will work but I can't figure out where to put it for additional fields... Any help?
  5. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    Sweet I figured it out on my own. I edited brick.php around line 1142 doing this

    PHP:
        function insertBrick(HTML_QuickForm2_Container $form)
        {
            
    $ifActive Am_Lite::getInstance()->haveSubscriptions(1);
            if (
    $ifActive==false) {
            }
            else
            {       
            
    $el $this->field->addToQF2($form);
            if (
    $this->getConfig('disabled'))
            
    $el->toggleFrozen(true);
            }
        }
  6. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    Hmm how would I modify this if I have 2 custom fields and I want to show field 1 if haveSubscriptions(1)

    or show both custom fields if haveSubscriptions(4);
  7. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    Need help with this urgently, anyone?
  8. kinitex

    kinitex Member

    Joined:
    Aug 28, 2009
    Messages:
    50
    Nevermind I finally figured it out using strpos to look for an instace in the field name to decide if I want to display it or not if havesubscription :)

Share This Page