Add “change author” functionality

Created on 2 September 2025, about 1 month ago

Problem/Motivation

I want to add functionality to set author information for a replicated page to the current user. I am not sure I understand how to use this module; if we want additional functionality, do we look to update this module? Or do we just add appropriate code to our own custom module?

Steps to reproduce

Replicate a page authored by someone other than yourself. Note replicated page maintains original author account.

Proposed resolution

Set the author to the current active user when replicating content.

Remaining tasks

Report mistakes in the associated issue fork (coming shortly).

User interface changes

None. Potentially a checkbox in the Replicate admin form if this is to be made a configurable change.

API changes

NA.

Data model changes

NA.

💬 Support request
Status

Active

Version

1.0

Component

Code

Created by

🇺🇸United States byronveale

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @byronveale
  • 🇺🇦Ukraine ruslan piskarov Kyiv, Ukraine

    Hey @byronveale.

    I think you can use hook_form_alter() in your custom module.
    Example:

    /**
     * Implements hook_form_alter().
     */
    function replicate_actions_form_alter(&$form, FormStateInterface $form_state, $form_id): void {
      if (strpos($form_id, '_replicate_form')) {
        /** @var \Drupal\replicate_actions\Form\ReplicateFormAlter $replicate_form_alter */
        $replicate_form_alter = \Drupal::service('replicate_actions.replicate_form_alter');
        $replicate_form_alter->alterForm($form, $form_state);
      }
    }
    

    Or implement your own EventSubscriber:
    class ReplicateChangeAutor implements ReplicateSetEntityEdit.

    However, if you can create a patch, I will add this functionality to the module. I think it is a great idea.

  • Pipeline finished with Canceled
    about 1 month ago
    #589122
  • Pipeline finished with Success
    about 1 month ago
    #589124
  • 🇺🇸United States byronveale

    Thanks @ruslan, I created a merge request here.

    I also added a patch to this comment.

    Any questions, do let me know…

  • 🇺🇦Ukraine ruslan piskarov Kyiv, Ukraine

    @byronveale, brilliant. I am going to review tomorrow. Thank you.

  • 🇮🇳India vinodhini.e chennai

    Hi, Steps to Reproduce the Issue and Verify the Fix

    Tested on Drupal 11.2.3.
    Installed and enabled Replicate and Replicate Actions modules.
    Created two users:
    User A → can create content
    User B → can replicate content

    Logged in as User A and created a Page (/node/add/page).
    Logged in as User B, went to the Page created by User A, clicked Replicate, and saved the replicated page.

    Before applying the patch: The replicated page author was User A (original author).

    Applied MR !12, cleared cache with drush cr, and repeated the same steps.

    After applying the patch: The replicated page author is now User B (replicating user).

    Its working fine. Thanks.

  • 🇺🇸United States bkosborne New Jersey, USA
  • Pipeline finished with Success
    about 1 month ago
    Total: 262s
    #589348
  • 🇺🇸United States byronveale

    Updated merge request based on code review (thanks @bkosborne), attaching updated patch too.

  • 🇺🇦Ukraine ruslan piskarov Kyiv, Ukraine

    Thank you @byronveale, @bkosborne and @vinodhini.e.
    Merget to master.

  • Now that this issue is closed, please review the contribution record.

    As a contributor, attribute any organization helped you, or if you volunteered your own time.

    Maintainers, please credit people who helped resolve this issue.

Production build 0.71.5 2024