dev-master
9999999-devGuest Entries Plugin for Craft CMS
The Requires
Wallogit.com
2017 © Pedro PelĂĄez
This plugin allows you to save guest entries from the front-end of your website., (*1)
This plugin requires Craft 2.0+., (*2)
To install Guest Entries, follow these steps:, (*3)
From the plugin settings page, you can configure which sections you want to allow guest entry submission to along with who the default author will be., (*4)
Every user you see in the default author list has âcreateEntryâ permissions for the section., (*5)
Your guest entry template can look something like this:, (*6)
You will need to adjust the hidden âsectionIdâ input to point to the section you would like to post guest entries to., (*7)
If you have a âredirectâ hidden input, the user will get redirected to it upon successfully saving the entry., (*8)
If there is a validation error on the entry, then the page will be releaded with a entry variable available to it, set to an EntryModel describing the submitted entry. You can fetch the posted values from that variable, as well as any validation errors via entry.getError(), getErrors(), or getAllErrors(). (The name of this variable is configurable via the entryVariable config setting.), (*9)
guestEntries.beforeSave eventOther plugins can be notified right before a guest entry is saved with the Guest Entries plugin, and they are even given a chance to prevent the entry from saving at all., (*10)
class SomePlugin extends BasePlugin
{
// ...
public function init()
{
craft()->on('guestEntries.beforeSave', function(GuestEntriesEvent $event) {
$entryModel = $event->params['entry'];
// ...
if ($isVulgar)
{
// Setting $isValid to false will cause a validation error
// and prevent the entry from being saved.
$entryModel->addError('title', 'Do you kiss your mother with those lips?');
$event->isValid = false;
}
if ($isSpam)
{
// Setting $fakeIt to true will make things look as if the entry was saved,
// but really it wasn't
$event->fakeIt = true;
}
});
}
}
guestEntries.success and guestEntries.error eventsPlugins can also listen to success and error events that get fired when a guest entry successfully gets saved or not., (*11)
Each of them has an entry parameter where you can access the EntryModel of the guest entry., (*12)
Additionally, success has a faked parameter so you can tell whether the success was a real one or a faked one., (*13)
Guest Entries has the following config settings:, (*14)
entryVariable - The name of the variable that submitted entries should be assigned to when the template is reloaded in the event of a validation error. Default is 'entry'.To override Guest Entriesâ config settings, create a new folder in your craft/config folder called guestentries, then put a config.php file inside of that at craft/config/guestentries/config.php. That file should returns an array of your custom config values., (*15)
<?php
return array(
'entryVariable' => 'guestEntry',
);
onSuccess and onError events.on position after being set to off.entryVariable config setting.Guest Entries Plugin for Craft CMS