Help me with cockpit

Very cool product! I like the admin panel. But I have a few things that I did not understand. I want to give users the ability to add content from the front-end. And here is what I did not understand at first glance at the cockpit:

  • User registration api? And i can not find user groups in admin panel…
  • Collections subcategory. Is it possible to create subcategories in collections to organize content?
  • I want sent email to user (activation link or similar) on registration and one on content submit

Hello,

https://getcockpit.com/documentation/api/cockpit

You can create user groups in the config file. or with the groups addon.

config.yaml example:

groups:
    guest:
        cockpit:
            backend: true

https://getcockpit.com/documentation/reference/configuration

Parent/child collections aren’t possible. You could create a collection with collection-link fields, that list all other collections… or you could enable “Custom sortable entries” to have child entries inside a collection.

You can use the event system. Add a snippet to /config/bootstrap.php

$app->on('collections.safe.after', function($name, &$entry, $isUpdate) {
    // send mail
});
$app->on('cockpit.accounts.save', function(&$data, $isUpdate) {
    if (!$isUpdate) // send mail
});

send mail (after you added your smtp options in your config file):

try {
    $options = []; // custom mailer options
    $response = $app->mailer->mail('post@example.com', 'subject', 'Hello, this is the mail content', $options);
} catch (\Exception $e) {
    $response = $e->getMessage();
}

https://getcockpit.com/documentation/api/cockpit

Thanks! I do not understand the process of creating a new user and his authorization. Should I give the user his Token for authorization? user should send an email and password, and if successful, get a token

The user system is meant to manage users with backend access, but you could use it for other users, too. Personally, I would create a collection with users and a custom api key with very limited rights to save contents in this collection.

Yes, that’s the default. Cockpit always needs a token for api calls. If you want to bypass it, you culd try this: