new_post
This endpoint will allow you to add new posts. You can also add CPT by providing type var. Featured image can also be attached with the post.
Custom fields can be added via `update_post_meta` endpoint using post_id.
`nonce` requirement can be disabled from Settings > UserPlus. Admin notification for any new submitted posts can also be enabled/disabled from Settings > UserPlus.
Note: User must have capability to add post. Change user role if needed or allow from the Settings > UserPlus > options.
Resource URL
http://localhost/api/userplus/new_post/
Method
POST
Required Parameters
- cookie - for user authentication
- nonce - available from the get_nonce method (call with vars controller=userplus and method=new_post)
- status - sets the post status ("draft" or "publish")
- title - the post title
- content - the post content
- key – get API key from Settings > User Plus
Optional Parameters
- type – Post Type. Default is `post`.
- categories - a comma-separated list of categories (URL slugs)
- tags - a comma-separated list of tags (URL slugs)
- attachment – upload field will cause an attachment to be stored with new post with image set as featured thumbnail
- post_meta - associative array of meta_key and meta_value. Any number of pair are supported.
Sample Request URL
http://localhost/api/userplus/new_post/
Sample Response
{
"status": "ok",
"post": {
"id": 2016159605276628,
"type": "post",
"slug": "",
"url": "https://www.domain.com/?p=2016159605276628",
"status": "draft",
"title": "New test Post with Post_meta",
"title_plain": "New test Post with Post_meta",
"content": "here is some content for test Post
\n",
"excerpt": "again updated content
\n",
"date": "2016-06-23 09:06:45",
"modified": "2019-09-25 17:40:16",
"categories": [],
"tags": [],
"author": {
"id": 1,
"slug": "ali",
"name": "Ali",
"first_name": "Ali",
"last_name": "Qureshi",
"nickname": "Ali",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "closed",
"custom_fields": {}
},
"post_meta": {
"country": 117293,
"city": 117294,
"zipcode": 117295
}
}