Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#337 2024-09-13 14:14:58

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 234
Website GitHub Mastodon

Re: mem_postmaster - Postmaster Revamp

jakob wrote #337851:

Does the message only show in debug mode? If so, it may only be a nuisance but no-one sees it when the site is set to live.

Yes I was in debug mode. Just changed to live to see what happens. Unfortunately, the error message still shows :/

Offline

#338 2024-09-13 15:01:24

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: mem_postmaster - Postmaster Revamp

As far as I recall, you don’t need to submit a form to unsubscribe. You should only need to detect the presence of the UID and then call one of the postmaster tags to action it. It’s been a while since I looked, but that is how I thought it worked.

If there is no UID, then you are correct that you can use a form to capture the email which postmaster can then look up to get the UID and unsubscribe them.

I can check later if I get a moment.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#339 2024-09-13 19:16:54

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 234
Website GitHub Mastodon

Re: mem_postmaster - Postmaster Revamp

Bloke wrote #337854:

As far as I recall, you don’t need to submit a form to unsubscribe. You should only need to detect the presence of the UID and then call one of the postmaster tags to action it.

oohh, aahh, I missed that !

So I could do :

<txp:com_connect thing>
    <txp:if_variable name="hasSubcribeId" value="">
    <-- process the email -->
    <txp:else/>
        <txp:com_connect_secret name="unsubscribeID">
         <txp:bab_pm_unsubscribe />
    </txp:if_variable>

I’ll test that, and I’ll report back

Offline

#340 2024-09-13 20:55:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: mem_postmaster - Postmaster Revamp

In theory, yes. I can’t remember if it actually works Iike that or if that’s how my replacement plugin I started (and have yet to finish) building works. Because that’s how I’d approach it.

Yiannis might know more, as he has this working on his site. Although I don’t know.of unsub requests are handled automatically by the plugin or if he gets a notification and then manually scrubs them from the lists.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#341 2024-09-16 07:58:24

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 234
Website GitHub Mastodon

Re: mem_postmaster - Postmaster Revamp

OK, reporting back :D

below is the working code that I used :

<txp:variable name="hasSubcribeId"><txp:page_url type="uid"/></txp:variable>
<txp:if_variable name="hasSubcribeId" value="">
    <txp:com_connect to="<admin_email>"
                     label="Se désabonner"
                     thanks="C’est fait ! Vous êtes désabonné.">
        <txp:com_connect_email name="subscriberEmail" label="Email" placeholder="email"
                               break=""
                               autocomplete="email"
                               required />
        <txp:com_connect_secret name="unsubscribeID" value=""/>
        <txp:com_connect_secret name="doSubscribe" value=""/>
        <txp:com_connect_secret name="unsubscribe" value="on"/>
        <button type="submit">Se désabonner</button>
    </txp:com_connect>
<txp:else/>
    <txp:bab_pm_unsubscribe/>
</txp:if_variable>

I found that bab_pm_unsubscribe was missing in the tag registry.
Added ->register('bab_pm_unsubscribe') at line 17.

The unsub request is handled automatiquely by bab_pm_unsubscribe.
But there is no success message, the plugin only provide an error message in case of error.
Is there a hook I could use to provide a feedback ?
Thanks

Offline

#342 2024-09-16 09:23:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: mem_postmaster - Postmaster Revamp

planeth wrote #337868:

Is there a hook I could use to provide a feedback ?

I haven’t checked and I don’t think there is, but in the meantime…

...
<txp:else/>
    <txp:bab_pm_unsubscribe/>
    <p>Your unsubscription request has been received. Sorry to see you go. Remember you can resubscribe at any time.</p>
</txp:if_variable>

And if you wanted to check if it returned anything, maybe this (untested) :

...
<txp:else/>
    <txp:evaluate not test="bab_pm_unsubscribe">
       <txp:bab_pm_unsubscribe/>
       <p>Your unsubscription request has been received. Sorry to see you go. Remember you can resubscribe at any time.</p>
    </txp:evaluate>
</txp:if_variable>

The theory being that if it returns something it’ll be an error, which means the test will succeed, so we invert the logic with not to make it only print the message if the tag returns empty.

I’m unsure if not works that way in the evaluate tag.

YMMV.

Last edited by Bloke (2024-09-16 09:28:57)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#343 2024-09-16 13:18:49

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 234
Website GitHub Mastodon

Re: mem_postmaster - Postmaster Revamp

The first option works.
The second not at all.

Problem solved :D Thanks Stef

Offline

#344 2024-09-16 15:37:24

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: mem_postmaster - Postmaster Revamp

Interesting case. You should be able to solve it with

    <txp:evaluate query test='<txp:bab_pm_unsubscribe/>'>
       <p>You are in trouble here.</p>
    <txp:else />
       <p>Your unsubscription request has been received. Sorry to see you go. Remember you can resubscribe at any time.</p>
    </txp:evaluate>

Offline

#345 2024-09-16 16:39:39

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,445
Website GitHub

Re: mem_postmaster - Postmaster Revamp

I was close! Thanks, Oleg. Forgot we need to put the whole expression in the test attribute. Nice one.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#346 2024-09-16 19:59:01

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: mem_postmaster - Postmaster Revamp

Bloke wrote #337873:

we need to put the whole expression in the test attribute.

Only in this rather special valueless query case. Your snippet was fine (and quite logical), it’s just that not does not work this way. A ‘normal’ tag detects which (true or false) part it should process before parsing it. The global not just inverses this choice. But <txp:evaluate /> must parse first its content to know whether it’s empty and only then eventually handle not attribute. I don’t think we have implemented this exception.

Offline

#347 2024-09-17 10:10:17

planeth
Plugin Author
From: Nantes, France
Registered: 2009-03-19
Posts: 234
Website GitHub Mastodon

Re: mem_postmaster - Postmaster Revamp

etc wrote #337874:

Only in this rather special valueless query case. Your snippet was fine (and quite logical), it’s just that not does not work this way. A ‘normal’ tag detects which (true or false) part it should process before parsing it. The global not just inverses this choice. But <txp:evaluate /> must parse first its content to know whether it’s empty and only then eventually handle not attribute. I don’t think we have implemented this exception.

Thanks Oleg for this thorough explanation. It should go in the wiki, no? What’s the modus operandi to update the wiki?

Offline

#348 2024-09-17 10:18:16

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

Re: mem_postmaster - Postmaster Revamp

Someone has to submit it :-) Also, I’d prefer not to document Easter eggs, they are hacky and subject to change.

Offline

Board footer

Powered by FluxBB