• Love the software – simply awesome!
    Two features I would love to see (that would be the icing on the cake):
    – The ability to change the author/creator of a post to someone else in the database. I’ve found myself in the position several times that I wanted to post content for someone else (e.g. an article was mailed to me) and didn’t want it to show up under MY name but that of the real author. Would be a great admin tool!
    – Revision/version tracking. With several people having edit rights, it would be cool to have the ability to scroll back to the original post if something went wrong. The previous drafts could be stored in a seperate database (so not to slow down the rest) with a button to clean it up once in a while.
    Thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • I second the request for ability to change the author of a post. MT allows this and I’ve found it indispensable.
    This goes on my list of things that, for now, keep me from being able to switch from MT to WP.

    Thread Starter Anonymous

    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.

    Thread Starter Anonymous

    hmm, _ should displays as underscore, but if you read this far you’ll know that already. ??

    Thread Starter Anonymous

    wp team should wrap this feature up in the 1.3 release!!!
    ??

    Or better still, make it a plugin ??
    I wonder what the stats are for single-user WP blogs, and multi-user ?

    No need for a plugin. The ability to edit post authors will be in 1.3.

    What about the revision history? I’d find something like that invaluable.

    I can’t get dotann’s code to work.
    I’m seeing the code from step #3 on the edit screen, beneath the post password. But no “combobox” is there.
    Also, it looks like maybe the code in that step got cut off? Is it supposed to begin with if ($user_level > 5) ?
    I’m just seeing el > 5) up there. Anyway, I tried both ways and I’m not having any luck.

    Thread Starter Anonymous

    emsdc, the code posted above were cut off somewhere, you can get the zipped copy of the three modified files (originally from 1.3 cvs) and try to merge the changes.

    Dotann, I’m getting this error:
    Database error: [You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ‘ORDER BY user_nickname’ at line 1]
    SELECT ID, user_nickname, user_firstname, user_lastname, user_nicename from ORDER BY user_nickname
    The error appears right under the post password field in the edit form.

    Thread Starter Anonymous

    emsdc, I just realized that you must be using version 1.2, the whole “$wpdb->users” syntax was introduced in the 1.3 alpha version, so these files has to be applied against the “bleeding edge” stuff…

    True. I’m using 1.2. Any idea when 1.3 will be done? Thanks…

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Changable authors and revision tracking’ is closed to new replies.