"Timed" Custom Capabilities (Jason Please Help Finalize)
Posted: January 14th, 2011, 6:08 pm
Like many, I've been trying to figure out how to handle custom capabilities that I want to last for a limited period of time. My solution is the following (I will post my code once I obfuscate and clean it up a bit).
Given a custom capability of: custom_timed_cap
When you initially provision the capability, always create TWO entries for the custom capability:
- custom_timed_cap
- custom_timed_cap_beg20110101_end20110201
this means that the capability should begin on 2011-Jan-01 and end on 2001-Feb-01
What my code does is, every night (or every hour or every 5 minutes) loops through your users, grabs all capabilities, looks for "timed" capabilities and adds/removes the capability as indicated.
What is important (to me) is that the "custom_timed_cap_beg20110101_end20110201" is NEVER removed. This way, I have a record of every custom capability that was provisioned.
I only use "custom_timed_cap" to determine if someone can access content.
Make sense?
Hopefully Jason will chime in on this.
Given a custom capability of: custom_timed_cap
When you initially provision the capability, always create TWO entries for the custom capability:
- custom_timed_cap
- custom_timed_cap_beg20110101_end20110201
this means that the capability should begin on 2011-Jan-01 and end on 2001-Feb-01
What my code does is, every night (or every hour or every 5 minutes) loops through your users, grabs all capabilities, looks for "timed" capabilities and adds/removes the capability as indicated.
What is important (to me) is that the "custom_timed_cap_beg20110101_end20110201" is NEVER removed. This way, I have a record of every custom capability that was provisioned.
I only use "custom_timed_cap" to determine if someone can access content.
Make sense?
Hopefully Jason will chime in on this.