diff --git a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts index e526017b52..a3bd42d74c 100644 --- a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts @@ -1,10 +1,16 @@ -import { OptionsWithUri } from 'request'; +import { + OptionsWithUri, +} from 'request'; + import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject } from 'n8n-workflow'; + +import { + IDataObject, +} from 'n8n-workflow'; export async function wordpressApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any const credentials = this.getCredentials('wordpressApi'); diff --git a/packages/nodes-base/nodes/Wordpress/PostDescription.ts b/packages/nodes-base/nodes/Wordpress/PostDescription.ts index d14f3b3292..9c390591d5 100644 --- a/packages/nodes-base/nodes/Wordpress/PostDescription.ts +++ b/packages/nodes-base/nodes/Wordpress/PostDescription.ts @@ -84,6 +84,16 @@ export const postFields = [ }, }, options: [ + { + displayName: 'Author ID', + name: 'authorId', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getAuthors', + }, + default: '', + description: 'The ID for the author of the object.', + }, { displayName: 'Content', name: 'content', @@ -287,6 +297,16 @@ export const postFields = [ }, }, options: [ + { + displayName: 'Author ID', + name: 'authorId', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getAuthors', + }, + default: '', + description: 'The ID for the author of the object.', + }, { displayName: 'Title', name: 'title', diff --git a/packages/nodes-base/nodes/Wordpress/PostInterface.ts b/packages/nodes-base/nodes/Wordpress/PostInterface.ts index ad4b378a1d..e810c11cf8 100644 --- a/packages/nodes-base/nodes/Wordpress/PostInterface.ts +++ b/packages/nodes-base/nodes/Wordpress/PostInterface.ts @@ -1,5 +1,6 @@ export interface IPost { + author?: number; id?: number; title?: string; content?: string; diff --git a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts index 93d4df9de9..6e8136959e 100644 --- a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts +++ b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts @@ -47,7 +47,7 @@ export class Wordpress implements INodeType { { name: 'wordpressApi', required: true, - } + }, ], properties: [ { @@ -115,6 +115,7 @@ export class Wordpress implements INodeType { async getAuthors(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const authors = await wordpressApiRequestAllItems.call(this, 'GET', '/users', {}, { who: 'authors' }); + console.log(authors); for (const author of authors) { const authorName = author.name; const authorId = author.id; @@ -147,6 +148,9 @@ export class Wordpress implements INodeType { const body: IPost = { title, }; + if (additionalFields.authorId) { + body.author = additionalFields.authorId as number; + } if (additionalFields.content) { body.content = additionalFields.content as string; } @@ -186,6 +190,9 @@ export class Wordpress implements INodeType { const body: IPost = { id: parseInt(postId, 10), }; + if (updateFields.authorId) { + body.author = updateFields.authorId as number; + } if (updateFields.title) { body.title = updateFields.title as string; }