0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Node cloneモジュールを使ってコンテンツをコピーするけど、特定のフィールドは値を引き継ぎたくない

0
Last updated at Posted at 2016-03-29

Node cloneモジュールを使ってコンテンツをコピーするけど、特定のフィールドは値を引き継ぎたくない

そんな時はこれ。

PHP
/**
 * Implements hook_clone_node_alter
 */
function MYMODULE_clone_node_alter(&$node, $context) {
    if ($context['original_node']->type !=== 'article_information') {
      return;
    }
  
    if (isset($node->field_email)) {
      unset($node->field_email);
    }

    if (isset($node->field_locale)) {
      unset($node->field_locale);
    }
}

備考

hook_clone_access_alter もあるので、アクセス制御が少し楽になるかもしれませんね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?