Repository navigation
Create a channel based on a frontend user regisration #12620
Unanswered
dolphiq-allard
asked this question in
Q&A
Replies: 1 comment 5 replies
|
I wouldn’t recommend this approach, as the UI was not designed for a very large number of sections. And sections are expected to only be created locally, as they are included in your project config, which should never change on production. You could give users a single entry within a single section. If they are the author you can use the existing author permissions to restrict their access to only save their own entry. Alternatively you could do your own permission enforcement, by hooking into the use craft\elements\Entry;
use craft\events\AuthorizationCheckEvent;
use craft\services\Elements;
use yii\base\Event;
Event::on(
Elements::class,
Elements::EVENT_AUTHORIZE_SAVE,
function(AuthorizationCheckEvent $event) {
if (
$event->element instanceof Entry &&
$event->element->getSection()->handle === 'userSectionHandle' &&
$event->element->someUserIdField == $event->user->id
) {
$event->authorized = true;
}
}
); |
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I am currently working on a project where I'd like frontend users to be able to register an account. This works like a charm using the Craft CMS tools out of the box.
However: based on a specific (custom) field in this registration e.g.
Company Display nameI'd like a channel to be automatically created with access only to the registered user using the custom field. So result should be a Channel named e.g.Pixel and Tonicin which the user can add entries which can be shared on the internet viahttps://example.com/pixel-and-tonic/example-entryGoal is to allow the user to allow CRUD on entries in this specific channel without being able to access/edit other users channels/entries.
What would be the best way to achieve this?
Cheers
All reactions