WSP-29 WP author byline by
This commit is contained in:
25
autoload.php
25
autoload.php
@@ -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'],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user