Expirationdate plugin for Elgg 5.0 and newer Elgg 5.X
Latest Version: 5.0.0
Released: 2024-11-01
Contact: iionly@gmx.de
License: GNU General Public License version 2
Copyright: (c) Brett Profitt (Original developer) / iionly (for Elgg 1.8 onwards), (*1)
Description
The Expirationdate plugin can be used to define a date of expiration for entities and to delete them automatically via a cron job. The plugin provides no user interface on your site (apart from setting the desired cron interval in the admin section)., (*2)
For example this plugin can optionally be used with the Elggx Userpoints plugin., (*3)
If you only intend to use the Expirationdate plugin in connection with another plugin that already has the expiration date mechanism implemented, you only need to enable it like another Elgg plugin and set the desired cron interval in the plugin's settings. Additionally, at least the cronjob for this interval must be configured on your server!, (*4)
If you intend to use the methods included in the Expirationdate plugin within your own plugin development, read on., (*5)
Installation
- If you have installed a previous version of the Expirationdate plugin plugin disable the plugin in the admin section of your site and then remove the expirationdate folder from the mod directory of your Elgg installation,
- Copy the expirationdate folder into the mod directory of your Elgg installation,
- Enable the Expirationdate plugin plugin in the admin section of your site and set the desired cron interval in the Expirationdate plugin settings.
Usage
Configure cron for Elgg as described in the Elgg documentation., (*6)
Install and enable the Expirationdate plugin. Be sure to set the plugin's period to something that will match nicely with your cron jobs., (*7)
Within your plugin, set entity expiration dates by saying:, (*8)
\Expirationdate::expirationdate_set($entity->guid, $expiration_date_string, bool);
where $expiration_date_string is a valid strtotime() string. If the 3rd parameter is true, the entity will be disabled instead of deleted., (*9)
Unset expiration dates by saying:, (*10)
\Expirationdate::expirationdate_unset($entity->guid);
Before entities are deleted the plugin_hook expirationdate:expirate_entity is called with $param set as:, (*11)
array('entity' => entity object), (*12)
If you register a function to this hook, the entity will not be deleted/disabled unless the function returns true., (*13)
Each entity that has an expiration date will be passed through the plugin hook expirationdate:will_expire_entity with the $param set as:, (*14)
array('expirationdate' => timestamp of expiration, 'entity' => entity object), (*15)
This can be used to send out warning emails, etc., (*16)