Forum

Thread tagged as: Problem, Members

PHP Member Has Tag not working

Hi Rachel & Drew,

I'm having a bit of trouble with the perch_member_has_tag function.

I'm using the following code to protect a custom region:

<?php
    if (perch_member_has_tag('l01s1m3')) {
        perch_content_custom('Season 1 Articles - Month 3', array(
            'template' => 'article_listing.html',
        ));
    } else {
        echo "Coming soon...";
    }
?>

In Perch, I have assigned the logged in member that tag, and I can confirm they are logged in by using login page that comes with the members app.

The page just displays 'coming soon' even though they have the tag.

The template for the region is:

    <perch:if exists="image">
        <div class="ccontent__article__c--wide">
            <div class="ccontent__article__image">
                <img src="<perch:content id="image" type="image" label="Image" width="1100" crop="true" help="Width is 1100px" divider-before="Images" order="3" />" alt="<perch:content id="title" type="text" label="Title" size="xl" required="true" title="true" order="1" />" />

                <div class="ccontent__article__image__caption">
                    <div class="ccontent__article__eta">Reading time:&nbsp;&nbsp;<div class="eta"></div></div>
                </div>
            </div>
        </div>
    </perch:if>

    <div class="ccontent__article__c">
        <a href="<perch:content id="slug" for="title" type="slug" suppress="false" />"><h1 class="ccontent__article__t"><perch:content id="title" type="text" /></h1></a>

        <perch:content id="article" type="textarea" label="Article" editor="markitup" markdown="true" textile="false" html="false" size="xxl" required="true" order="2" />

        <select class="rating">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
        </select>

<perch:content id="slug" for="title" type="slug" suppress="true" />
<perch:content id="thumbnail" type="image" label="Thumbnail" width="331" crop="true" help="Width is 331px" suppress="true" order="4" />
<perch:content id="thumbnail-retina" type="image" label="Thumbnail - Retina" width="662" crop="true" help="Width is 662px" suppress="true" order="5" />

Here is my diagnostic report:

Perch: 2.8.29, PHP: 5.6.22, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.29), assets (2.8.29), categories (2.8.29), perch_blog (5.0), perch_shop_orders (1.0.6), perch_shop_products (1.0.6), perch_shop (1.0.6), perch_members (1.5), perch_podcasts (1.2), perch_mailchimp (3.0.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_shop', 'perch_blog', 'perch_podcasts', 'perch_mailchimp', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/helple/public_html/2016/perch
PERCH_CORE: /home/helple/public_html/2016/perch/core
PERCH_RESFILEPATH: /home/helple/public_html/2016/perch/resources
Image manipulation: GD
PHP limits: Max upload 64M, Max POST 8M, Memory: 96M, Total max file upload: 8M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
DOCUMENT_ROOT: /home/helple/public_html/2016
HTTP_HOST: 2016.helpingleader.com
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Elliot Davies

Elliot Davies 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

How were they assigned the tag? Have they logged in since it was assigned?

I just tried logging out, and then back in and it works.

face palm

I tried that before! I can't believe it works now.

So I guess if tags are set in Perch Admin, I need to re-login before they take effect.

Thanks Drew! :)