Skip to content

Allow autoPublish for user types #70

@FlorianBoe

Description

@FlorianBoe

👋 Hi Maurice, thanks for this great plugin!
The new version has also turned out very well.

I have a use case that cannot be implemented with the plugin at the moment, but I think it could be quite helpful to others as well.

I have a comment area where comments should be published automatically depending on the user type (blueprint). For example, all admins or editors. However, this list is dynamic and cannot be mapped using a static array of e-mail addresses in the config.

I think the function could be solved by moderation.autoPublish not only accepting an array, but also a closure that returns the permitted e-mail addresses. Like…

'autoPublish' => function () {
	$allowedEmails = [];
	$users = kirby()->users()->filter(function($user) {
		return $user->blueprint()->name() === 'users/admin' || $user->blueprint()->name() === 'users/editor';
	});

	foreach($users as $user) {
		$allowedEmails[] = $user->email();
	}

	return $allowedEmails;
}

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions