1

TL;DR question: How To Change Post Author Default?

Original question: How to make admins always post as blogger (blogger set as author), when posting on a bloggers blog?

What I want is to either enable a setting (most preferable), or install a plugin, or write a custom plugin (least preferable) so that:

An admin (or super-admin) on a multi-site can add a new blog post to any blog on the network "as the blog owner himself", without having to log in as the blog owner.

I know it is possible to create a blog post draft, then quick edit to change the author to the blog owner, then publish the blog post. This works, but it is cumbersome to do this every time, since it will be a part of the main process of how this blog network will work. What I need is a setting so that any admin can just create a post on a blog and publish it immediately, and the post should have the blog owner as the author (and not the admin as the author).

This is to enable that VIP bloggers can just send their blog posts by email to any admin, and the admin can post the blog post on their behalf.

Update: Simplified the question.

1
  • I'm afraid plugin recommendations are off topic. You could try searching the plugin directory, I remember even writing such a plugin couple of years ago over there;-) If you want to write one yourself, you could e.g. try the wp_insert_post_data filter.
    – birgire
    Sep 29, 2015 at 16:54

1 Answer 1

1

You just create must-use plugin for your multisite instalation (https://codex.wordpress.org/Must_Use_Plugins), hook to post save action there (https://codex.wordpress.org/Plugin_API/Action_Reference/save_post), and inside action callback check if current user is admin/super admin (https://codex.wordpress.org/Function_Reference/is_super_admin), if so, you find current blog user with 'author' role (https://codex.wordpress.org/Function_Reference/get_users) and update post (https://codex.wordpress.org/Function_Reference/wp_update_post) with his ID as author ID. At least it is first, quick&dirty solution which comes to mind.

3
  • Thanks. Could you go into a bit more detail on the you find current blog user with 'author' role (https://codex.wordpress.org/Function_Reference/get_users) part?
    – Magne
    Oct 1, 2015 at 12:01
  • I edited your post and added some detail on how I presume you intended for me to get the blog's authors. However, won't this get all authors, including super-admins? since who - If set to 'authors', only authors (user level greater than 0) will be returned.
    – Magne
    Oct 1, 2015 at 12:09
  • 1
    Read this: codex.wordpress.org/Roles_and_Capabilities An then just query users by role with get_users function. Oct 4, 2015 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.