WSP-29 WP author byline by

This commit is contained in:
Filip Penkava
2017-01-20 10:07:15 +01:00
parent 3cebf005c3
commit 8a19a64615
3 changed files with 48 additions and 2 deletions

View File

@@ -30,12 +30,35 @@ if ($obj['type'] == 'composite') {
wp_update_post($edit_post);
} else {
if ($settings['author-byline'] && $settings['author-byline'] == 'on') {
$author_name = str_replace("By ", "", $obj['byline']);
$authorExist = $wpdb->get_row("SELECT ID user_id FROM " . $wpdb->prefix . DB_TABLE_USERS . " WHERE display_name = '" . wp_strip_all_tags($author_name) . "'");
if (!$authorExist) {
$table_name = $wpdb->prefix . DB_TABLE_USERS;
$userArray = array(
'user_login' => strtolower(str_replace(" ", "-", $author_name)),
'user_pass' => generatePassword(),
'display_name' => wp_strip_all_tags($author_name)
);
$author_id = wp_insert_user($userArray);
} else {
$author_id = $authorExist->user_id;
}
} else {
$author_id = $settings['author'];
}
$postarr = array(
'post_title' => wp_strip_all_tags($obj['headline']),
'post_name' => wp_strip_all_tags($obj['headline']),
'post_content' => $content,
'post_content_filtered' => $content,
'post_author' => (int) $settings['author'],
'post_author' => (int) $author_id,
'post_status' => $settings['status'],
'post_category' => $settings['category'],
);