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.

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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

byronveale created an issue. See original summary.

byronveale’s picture

Issue summary: View changes
ruslan piskarov’s picture

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.

byronveale’s picture

Thanks @ruslan, I created a merge request here.

I also added a patch to this comment.

Any questions, do let me know…

ruslan piskarov’s picture

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

ruslan piskarov’s picture

Status: Active » Needs review
vinodhini.e’s picture

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.

bkosborne’s picture

Status: Needs review » Needs work
byronveale’s picture

StatusFileSize
new6.18 KB

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

ruslan piskarov’s picture

Category: Support request » Feature request
Status: Needs work » Fixed

Thank you @byronveale, @bkosborne and @vinodhini.e.
Merget to master.
Created 8.x-1.8.

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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.