Co-Authors-Plus icon indicating copy to clipboard operation
Co-Authors-Plus copied to clipboard

CAP removes the Author field in bulk edit actions

Open TheCrowned opened this issue 6 years ago • 10 comments

Without CAP, it's possible to bulk edit post author:

wo cap 2

With CAP active, the field vanishes and no coauthor field is added in replacement:

w cap

TheCrowned avatar Jul 04 '18 08:07 TheCrowned

I think we should wait to fix this issue, here's why. I started working on a fix for that in a separate forked repo: https://github.com/psaikali/Co-Authors-Plus/commit/2ac1afbacaec965bbd35bbdd569b8eeb3c160c03

cap-bulk-edit-coauthors As you can see, the UI is ready. I just need to process the bulk action when editing multiple posts, and that's where things get complicated.

The main core function taking care of this bulk editing action is bulk_edit_posts(). Unfortunately, this function does not offer any hook to let us save additional data when bulk editing. There is a ticket for that here and it looks like the bulk_edit_posts hook will show up in 5.0 (very soon).

IMHO, it's better to wait for this official hook and use it to easily process the bulk-edit action and assign co-authors to multiple posts at the same time. I started to find another way to do that, by hooking to another action (wp_insert_post is triggered by the bulk_edit_posts() function) and checking for $_POST data, but I feel that this is a hacky way of doing things knowing that a proper hook might be available in a couple of months.

Any feedback is appreciated!

psaikali avatar Aug 02 '18 12:08 psaikali

Just ran into this myself. Looks like we'll have to wait for 5.0.2 for the bulk_edit_posts to be completed.

DailenG avatar Dec 13 '18 16:12 DailenG

Is this fix still in progress?

jadlimcaco avatar Jun 10 '19 22:06 jadlimcaco

This is still an issue as of May, 2020, any update?

colorcrate avatar May 11 '20 18:05 colorcrate

This would be so useful! Any word?

jxxe avatar May 20 '20 02:05 jxxe

Also looking for this update

melmo avatar Jun 09 '20 04:06 melmo

Bump

RubenatorX avatar Sep 18 '20 20:09 RubenatorX

@psaikali are you still working on this? Otherwise I can take over and hopefully fix it for good :)

After all, it looks like the bulk_edit_posts action won't be a thing. But it also looks like the wp_insert_post_data hook is enough for our purpose. It does contain all the details we need to then call add_coauthors on each post ID with given authors. This is an example var_dump of the second argument of the action:

array (size=47)
...
  'ID' => int 10673
...
  'coauthorsinput' => 
    array (size=3)
      0 => string 'Giacomo Lana' (length=12)
      1 => string 'admin' (length=5)
      2 => string 'Search for an author' (length=20)
  'coauthors' => 
    array (size=2)
      0 => string 'et-1' (length=4)
      1 => string 'admin' (length=5)
  'coauthors-nonce' => string '81d49936a3' (length=10)
  'bulk_edit' => string 'Aggiorna' (length=8)
...
  'post' => 
    array (size=2)
      0 => string '10673' (length=5)
      1 => string '10633' (length=5)
  'action2' => string '-1' (length=2)
  'post_ID' => int 10673
  'user_ID' => int 1
  'filter' => string 'db' (length=2)

it looks to me the two entries coauthors and post are enough.

TheCrowned avatar Sep 25 '20 02:09 TheCrowned

Tell me please, is there any news on this issue?

tiberium84 avatar Apr 09 '22 18:04 tiberium84

Tell me please, is there any news on this issue?

You can check the PR: https://github.com/Automattic/Co-Authors-Plus/pull/747 A fix was submitted, but it causes issues so, someone has to fix the fix.

RubenatorX avatar Apr 13 '22 21:04 RubenatorX