pipit_members_add_tag()
Add a tag to member (even if they are not logged in).
pipit_members_add_tag($tag, $id_or_email=0, $expiry_date=false)
This is useful when you need to programmatically add a tag to a Perch member that is not logged in. Examples:
- Perch event listener
- webhooks
Parameters
Type | Description |
---|---|
String | Tag to add |
Int/String | Member ID or email. Set to 0 to target the logged in member. |
Date | Optional expiry date |
Usage
// by email address
pipit_members_add_tag('subscriber', '[email protected]');
// by ID
pipit_members_add_tag('subscriber', 34);
// with expiry date
pipit_members_add_tag('subscriber', 34, '2030-02-23');
// relative expiry date
pipit_members_add_tag('subscriber', 34, '+3 months');
If you are using Stripe webhooks, you may use something like this:
switch($event->type) {
case 'invoice.payment_succeeded':
$customer_email = $event->data->customer_email;
pipit_members_add_tag('subscriber', $customer_email, '+1 year');
break;
// other event types
}