Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow autoPublish for user types #70

Open
FlorianBoe opened this issue Mar 25, 2025 · 0 comments
Open

Allow autoPublish for user types #70

FlorianBoe opened this issue Mar 25, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@FlorianBoe
Copy link
Contributor

FlorianBoe commented Mar 25, 2025

👋 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants