Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Thomas

Author select fix & ACP action buttons

Hi,

WP has a bug where some authors/users are missing form the author select when editing posts. It seems that a custom fix for this (below) doesn’t play nicely with the ACP action buttons, each time they’re used the author changes to last user in the author select.

add_filter('wp_dropdown_users', 'MySwitchUser');
function MySwitchUser($output)
{

global $post;
//global $post is available here, hence you can check for the post type here
$users = get_users();

$output = "<select id=\"post_author_override\" name=\"post_author_override\" class=\"\">";

//Leave the admin in the list
$output .= "<option value=\"1\">Admin</option>";
foreach($users as $user)
{
$sel = ($post->post_author == $user->ID)?"selected='selected'":'';
$output .= '<option value="'.$user->ID.'"'.$sel.'>'.$user->user_login.'</option>';
}
$output .= "</select>";

return $output;
}

PS: Directly after using a ACP action button, the table line layout for the corresponding post is off, basically the action buttons and all columns after them to the right are gone (plus a few other on the left).

Cheers,
Thomas

5 years, 5 months ago
Stefan
Developer

Hi Thomas,

Please can you explain to me which ACP action buttons you mean?
I tried to reproduce your ticket and did the following:

1) Tested your filter with a post and changed the author field (check, new author is saved)
2) Go back to the overview and click on some of our action buttons (filter, edit columns) but none of those actions changed the author value.

Maybe you are talking about quick edit. There is a known bug that when you use quick edit and save the post, that not the correct columns for that row are loaded (though ajax). There is a fix for this in the upcoming release. If this is not the case (quick edit) please can you describe the exact steps to me so I can reproduce the issue?

5 years, 5 months ago
Thomas

Hi there,

Yes, I’m talking about QuickEdit. Basically, I’m clicking the ACP button for editing (on the post overview page) and change the post status. After that the wrong author is selected. Without the author select fix snippet posted above the problem doesn’t occur.

Cheers,
Thomas

5 years, 5 months ago
Stefan
Developer

Hi Thomas,

I still cannot reproduce the issue in the current release and our developing environment.
These are the stept I’m trying to reproduce the issue:

1) Going to post overview
2) Change Post status with inline edit (pencil in Status column)
3) Without refresh click on quick edit button. The author is as expected.

This seems logic because when changing the status, we don nothing else than changing the status (or any other field). Can you check that when you click on edit post instead of quickedit that the problem also occurs?

– Update –
After debugging the code you send me, it seems that is has nothing to do with our plugin. Even when you disable our plugin, the problem still occurs. The problem is that when you use Quick Edit, the $post variable is not set and available. In your code you use the global $post variable but you don’t have it when using quick edit.

So you’ll have to find a way to get the correct $post when using quick edit. I believe all quick edit logic except for the save action is done by javascript.

5 years, 5 months ago
Stefan
Developer

You’re welcome :)
I will close the ticket

5 years, 5 months ago
Stefan
Developer

Thanks for the info.
The solution works for add/edit posts but not for quick edit.

5 years, 5 months ago
Marcelo

taking advantage of the topic …

when I select the edition in line and I change an author of a particular post, ok works perfectly, it happens that when this new author enters the post and makes some changes and saves the update immediately post back to belong to the author of origin … know tell me why this happens?

5 years ago

You must be logged in to reply to this topic.