• Here’s a patch that will have wp-email.php look up the mail sender’s from address and assign the post to that author if registered.

    *** wp-mail.php.orig Mon Jun 21 23:41:28 2004
    --- wp-mail.php Fri Jun 18 16:43:50 2004
    ***************
    *** 60,65 ****
    --- 60,72 ----
    $subject = wp_iso_descrambler($subject);
    }
    }
    + if (preg_match('/From: /i', $line)) {
    + $from = trim($line);
    + $from = str_replace('From: ', '', $from);
    + if (preg_match('/<(.*)>/', $from, $matches)) {
    + $from = $matches[1];
    + }
    + }
    if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37'
    $ddate = trim($line);
    $ddate = str_replace('Date: ', '', $ddate);
    ***************
    *** 120,126 ****
    $content = preg_replace("|\n([^\n])|", " $1", $content);
    $content = addslashes(trim($content));
    ! $sql = "INSERT INTO $tableposts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES ('1', '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_date', '$post_date_gmt')";
    $result = $wpdb->query($sql);
    $post_ID = $wpdb->insert_id;
    --- 127,140 ----
    $content = preg_replace("|\n([^\n])|", " $1", $content);
    $content = addslashes(trim($content));
    ! $post_author = $wpdb->get_row("SELECT ID FROM wp_users WHERE user_email = '$from'", "ARRAY_N");
    ! if ($post_author == '') {
    ! $post_author = '1';
    ! } else {
    ! $post_author = $post_author[0];
    ! }
    !
    ! $sql = "INSERT INTO $tableposts (post_author, post_date, post_date_gmt, post_content, post_title, post_modified, post_modified_gmt) VALUES ('$post_author', '$post_date', '$post_date_gmt', '$content', '$post_title', '$post_date', '$post_date_gmt')";
    $result = $wpdb->query($sql);
    $post_ID = $wpdb->insert_id;
    ***************
    *** 134,141 ****
    echo "\n<b>Posted author id:</b>
    <pre>".$post_author.'</pre>';
    echo "\n<b>Posted content:</b>
    <pre>".$content.'</pre>';
    -
    -
    if (!$post_categories) $post_categories[] = 1;
    foreach ($post_categories as $post_category) :
    $post_category = intval($post_category);
    --- 148,153 ----

Viewing 3 replies - 1 through 3 (of 3 total)
  • Just two small questions, if you will. 1) How do you install it? 2) Is it possible to simply pass along the email address without validating it agains the user database?
    Thanks. Dalton

    Thread Starter disser

    (@disser)

    Dalton, you need the unix “patch” program to apply my patch to your wp-email.php script. Just copy the lines to a file, then <b>patch < file</b>.
    Also, any emails that are not in the user database will be owned by the admin user as before.

    Thanks! Got it now. I’m newish to the Unix world (been using Linux since 1999, but only recently have I done anything serious with it) and am still getting my legs.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Set post author in wp-email.php’ is closed to new replies.