Is it possible to make a content rule for 'first login'? Maybe by using a TALES expression looking for 'last login' (which used to be a certain date if user had not logged in before).
Plone users are not content and therefore the question makes no sense.
See
or collective.onlogin
as an inspiration how to handle your usecase.
So I assume that means that a TALES expression can not do something similar to api.user.get_current() ? (there is already a 'user logged in content rule', but I have never used it.
There's a IUserInitialLoginInEvent
event. I don't know if you can use it as a triggering event OOTB.
You can also do Products.PlonePAS/src/Products/PlonePAS/tools/membership.py at d148e7eb50e52cddf954406c06026fb5e60f3da7 · plone/Products.PlonePAS · GitHub in a content rule for a user logged in
event.
Thanks. It looks like this could work:
<interface
interface="Products.PlonePAS.interfaces.events.IUserInitialLoginInEvent"
type="plone.contentrules.rule.interfaces.IRuleEventType"
name="User Logged in first time"
/>
<subscriber
for="Products.PlonePAS.interfaces.events.IUserInitialLoginInEvent"
handler=".handlers.user_logged_in_first"
/>
handlers.py
from plone.app.contentrules.handlers import execute_user_rules
def user_logged_in_first(event):
"""When a user is logged in first time, execute rules assigned to the Plonesite."""
execute_user_rules(event)
2 Likes