Here’s a brief recount of my changes to the admin interface to enable “user switching” in the edit interface. Hope my source code displays correctly..
1. Add a function to output a combobox in wp-includes/template-functions-author.php
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php”>
// This is used in post.php to change a post’s user
function wp_dropdown_authors($show_fullname=false,
$exclude_admin=false) {
global $wpdb, $blogfilename;
global $authordata;
$selected = $authordata->ID;
$query = “SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from $wpdb->users ” . ($exclude_admin ? “WHERE user_nickname <> ‘admin’ ” : ”) . “ORDER BY user_nickname”;
$authors = $wpdb->get_results($query);
echo ‘<select name=”author_ID” id=”author_ID”>’;
foreach($authors as $author) {
$name = $author->user_nickname;
if ($show_fullname && ($author->user_firstname != ” && $author->user_lastname != ”)) {
$name = “$author->user_firstname $author->user_lastname”;
}
echo “\t<option value=\””.$author->ID.”\””;
if ($author->ID == $selected)
echo ‘ selected=”selected”‘;
echo ‘>’;
echo $name;
echo “</option>\n”;
} // foreach($authors as $author)
echo “</select>\n”;
}
</></pre>
2. Find the div that contains post password in wp-admin/edit-form-advanced.php
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php”>password” type=”text” size=”13″ id=”post_password” value=”< ?php echo $post_password ?>”</></pre>
3. Add a combobox that contains a list of registered authors underneath it.
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php”>el > 5) { // enable author change for user_level 5
echo “<div>”;
wp_dropdown_authors();
echo “</div>”;
} ?>
</pre>
4. Edit wp-admin/post.php, to save the selected author ID together with the post.
Find the line to check the userlevel
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php”>
if ($user_level == 0)
die (__(‘Cheatin’ uh?’));
</pre>
Add a line to check the selected post author ID
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php”>
if (($user_level > 5) && (!empty($_POST[‘author_ID’]))) {
$author_ID = $_POST[‘author_ID’];
} else {
$author_ID = $user_ID;
}
</pre>
Find the sql statement that saves / updates the post. (the similiar statement occured twice in the file).
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php>
$postquery =”INSERT INTO $wpdb->posts
(ID, post_author, post_date, post_date_gmt, post_content, post_title, post_lat, post_lon, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, post_modified, post_modified_gmt)
VALUES
(‘0’, ‘$user_ID’, ‘$now’, ‘$now_gmt’, ‘$content’, ‘$post_title’, $post_latf, $post_lonf,’$excerpt’, ‘$post_status’, ‘$comment_status’, ‘$ping_status’, ‘$post_password’, ‘$post_name’, ‘$trackback’, ‘$now’, ‘$now_gmt’)
“;
</pre>
Change the$user_ID to $author_ID in this query.
4. Edit the following query in the same file:
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php”>
$result = $wpdb->query(“
UPDATE $wpdb->posts SET
post_content = ‘$content’,
post_excerpt = ‘$excerpt’,
post_title = ‘$post_title'”
.$datemodif_gmt
.$datemodif.”,”
.$latlonaddition.”
post_status = ‘$post_status’,
comment_status = ‘$comment_status’,
ping_status = ‘$ping_status’,
post_password = ‘$post_password’,
post_name = ‘$post_name’,
to_ping = ‘$trackback’,
post_modified = ‘$now’,
post_modified_gmt = ‘$now_gmt’
WHERE ID = $post_ID “);
</pre>
and add the following line to modify post_author
<pre style=”padding-left: 15px; margin-left: 5px; border-left: 1px solid #4A7184;line-height: 140%; white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;word-wrap: break-word;” lang=”php”>
post_modified_gmt = ‘$now_gmt’,
post_author = ‘$author_ID’
WHERE ID = $post_ID “);
</pre>
You can get the source code (at the bottom of the page) and look at the screen shot at CNWP, the article there is written in chinese, let me know if you need some clarification.