PHPackages                             ctigelaar/craft-guestentries - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ctigelaar/craft-guestentries

ActiveCraft-plugin

ctigelaar/craft-guestentries
============================

Guest Entries Plugin for Craft CMS

126PHP

Since Jul 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ctigelaar/craft-guestentries)[ Packagist](https://packagist.org/packages/ctigelaar/craft-guestentries)[ RSS](/packages/ctigelaar-craft-guestentries/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Guest Entries plugin for Craft
==============================

[](#guest-entries-plugin-for-craft)

This plugin allows you to save guest entries from the front-end of your website.

Requirements
------------

[](#requirements)

This plugin requires Craft 2.0+.

Installation
------------

[](#installation)

To install Guest Entries, follow these steps:

1. Upload the guestentries/ folder to your craft/plugins/ folder.
2. Go to Settings &gt; Plugins from your Craft control panel and enable the Guest Entries plugin.
3. Click on “Guest Entries” to go to the plugin’s settings page, and configure the plugin how you’d like.

Settings
--------

[](#settings)

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.

Every user you see in the default author list has “createEntry” permissions for the section.

Usage
-----

[](#usage)

Your guest entry template can look something like this:

```

    {{ getCsrfInput() }}

    Title

    Body

```

You will need to adjust the hidden “sectionId” input to point to the section you would like to post guest entries to.

If you have a “redirect” hidden input, the user will get redirected to it upon successfully saving the entry.

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](http://buildwithcraft.com/docs/templating/entrymodel) describing the submitted entry. You can fetch the posted values from that variable, as well as any validation errors via [`entry.getError()`](http://www.yiiframework.com/doc/api/1.1/CModel#getError-detail), [`getErrors()`](http://www.yiiframework.com/doc/api/1.1/CModel#getErrors-detail), or [`getAllErrors()`](http://buildwithcraft.com/classreference/models/BaseModel#getAllErrors-detail). (The name of this variable is configurable via the `entryVariable` config setting.)

### The `guestEntries.beforeSave` event

[](#the-guestentriesbeforesave-event)

Other 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.

```
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` events

[](#guestentriessuccess-and-guestentrieserror-events)

Plugins can also listen to `success` and `error` events that get fired when a guest entry successfully gets saved or not.

Each of them has an `entry` parameter where you can access the `EntryModel` of the guest entry.

Additionally, `success` has a `faked` parameter so you can tell whether the success was a real one or a faked one.

Configuration
-------------

[](#configuration)

Guest Entries has the following config settings:

- `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.

```
