Skip to content

Disallow Duplication of Elements #15122

Closed Answered by brandonkelly
shifuma asked this question in Q&A
Discussion options

You must be logged in to vote

Create a module with the following code:

use Craft;
use craft\elements\actions\Duplicate;
use craft\elements\Entry;
use craft\events\AuthorizationCheckEvent;
use craft\events\RegisterElementActionsEvent;
use craft\services\Elements;
use yii\base\Event;

// Remove the “Duplicate” bulk action on entry indexes
Event::on(Entry::class, Entry::EVENT_REGISTER_ACTIONS, function(RegisterElementActionsEvent $event) {
    $event->actions = array_filter($event->actions, function($action) {
        $type = is_array($action) ? $action['type'] : $action;
        return $type !== Duplicate::class;
    });
});

// Prevent the “Save as a new entry” action on entry edit pages
Craft::$app->elements->on(Elements

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants