Forum

Thread tagged as: Question, Members

Set member Tag

Hi All

Im sure in the documentation you could set a member tag using php

also can you change a tag expiry date

what i want to happen is if a member buys a product they get given a tag that will expire on a set date

Anthony Elleray

Anthony Elleray 2 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What have you set under the Tags tab within your product?

I have not added a tag yet

But i want to set a tag called "member"
and i want the tag to expire on 31st December but the options only alloy days, weeks ect not set dates

the idea being if a customer buys the product in Jan the tag will expire on the 31st December if a customer buys a product in Aug it will expire 31st December

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you'd need to do that with

perch_member_add_tag($tag, $expiry_date);

Found the Documentation im sure the new Docs are harder to find stuff

https://docs.grabaperch.com/functions/members/perch-member-add-tag/

Basically need this for perch shop products

<?php perch_member_add_tag('subscriber', '2016-01-23'); ?>

Feature request :)

Drew McLellan

Drew McLellan 2638 points
Perch Support

You don't need a feature to do that - you have everything you need.

Thanks :) Life saver

i have this in my header

<?php if (perch_member_logged_in() && perch_member_has_tag('member')) { 
                perch_shop_enable_trade_pricing();
                perch_member_add_tag('member', '2016-12-31'); 
            }
        ?>
<!doctype html>

but its not updating the expiry date on the member tag

the same code works adding a new tag just not updating an existing one

Drew McLellan

Drew McLellan 2638 points
Perch Support

I don't believe perch_member_add_tag() will update a tag. It's designed to add a tag.

in the docs it says it will update

"Updating a tag Adding a tag to a member will replace any existing instance of that tag for that member. This enables tags to be updated."

Drew McLellan

Drew McLellan 2638 points
Perch Support

There we go then - sounds like it does update it.

the tag is set by the shop

and then this is at the top of the header before any html

<?php if (perch_member_logged_in() && perch_member_has_tag('member')) {  
perch_shop_enable_trade_pricing(); 
perch_member_add_tag('member', '2016-12-31'); 
 } ?> 
<!doctype html>

and still not updating

Duncan Revell

Duncan Revell 78 points
Registered Developer

Just as a test, have you tried perch_member_remove_tag() and then perch_member_add_tag()?

i managed to do it like this

<?php if (perch_member_logged_in() && perch_member_has_tag('holiday')) { 
        perch_member_add_tag('holiday_VIP', '2016-12-31'); 
    }
     if (perch_member_logged_in() && perch_member_has_tag('holiday_VIP')) { 
        perch_shop_enable_trade_pricing();
    }
?>