I figured out the answer myself and I’ll post it here in case anyone else has this problem. Basically in WP 3.9.1, wp_insert_post()
checks the current logged in user for account capabilities (at least this is what I assume). Since I was connecting over cURL, there is no logged in user so the capability checks fail. All I had to do was send the cookie WP uses to remember logged in users:
$curl = curl_init( 'http://www.domain.com' );
$login_cookie="wordpress_logged_in_[hash]=xxx"; // This cookie can be found once a user is logged in.
curl_setopt( $curl, CURLOPT_COOKIE, $login_cookie );
So I simply set up a new admin account for my external application, logged it as that account (using /wp-admin), copied the cookie that WP made for me, and added it to my application.
Related Posts:
- Connection lost. Saving has been disabled… (Updating Posts/Pages)
- Fatal error: Call to undefined function post_exists()
- Sql syntax error
- Fatal error post.php help :(
- ‘Invalid post type’ error when importing from one site to another
- How to automate filing a form as a user
- Create a WordPress post using curl comand from Linux console?
- PHP Notice error (when on 404 page)
- Getting a 404 error when clicking edit page
- White Blank Page when Updating and Publishing Page/Post
- How to create a post using REST API with sending data as a JSON body?
- Classic editor throws 403 error based on post content
- XML-code sent via the POST method to the URL (API) [closed]
- Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
- why are images not full size?
- Blank page when saving edits on post
- What do these phpMyAdmin errors mean on my WordPress databaes?
- getting “Object of class WP_Post could not be converted to string” – when it is a string
- My post does not show up
- Featured Images most often doesnt appear
- WordPress Post 403 Error Based on Slug
- My posts are getting to Auto draft when I try to Publish
- Many buttons not functioning in WordPress dashboard (as admin)
- All my posts don’t show, only the headline is displayed on the homepage
- Get post title by Alphabet
- Admin notice on wp_insert_post
- Posts Page in WordPress loading bare HTML of my homepage
- How to get post creation date?
- Confirmation box when submitting post for review
- How to show list of posts by author and category?
- Change slug with custom field
- Insert custom div between posts
- How to Display Post View Count
- Remove double space after a period
- Displaying the number of posts in a custom loop (without including the number of posts of a loop below)?
- display order of connections
- Warning: Creating default object from empty value in … /post.php
- Conditional that checks if a current category has any subcategory with posts
- Display page content AFTER a loop of posts
- How to get the date of a post in WordPress, so I could use it in a script?
- Unwanted Duplicate Posts Showing in Pagination Pages
- Downgrade user from role that allows post creation
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- Add code just after Post content
- Alternating post layout
- Articles are text-only in any “Category” instead of HTML
- How to get the user meta data for a post?
- Auto insert More tags in all posts
- Get current category id from post page wordpress
- How to change post status from frontend?
- How to show last post of each website of a MU wordpress in HomePage
- Retrieve value between 2 post
- How to get next post ID?
- How to display content from the main blog on another from multisite network as it would be its own
- After database migration, posts not showing up in dashboard
- how to replace source ” https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css” in the wordpress backend?
- Display an author’s posts on his own author page
- Static posts page with home.php
- Start WP Pagination From Number 1 in URL
- Avoiding “Missed Schedule” errors when inserting future posts
- Using setup_postdata() with multi-dimensional array
- Deleting post specific content at beginning of post
- How to display the requested post only?
- Export all posts to import as product items
- Prevent duplicate pages from being added
- Can I style single post that are in multiple catergories?
- Older blog posts not showing up on WordPress
- Embedding Post Editor Into External Site
- Show single post child category from a determined parent
- Go back to the exact post page number
- Pagination Stops
- How to mark only one post as Featured post?
- Remove status ‘archived’ from the default post and page view
- How to invoke a HTML custom button based on a HTML dropdownlist menu
- Post data across WordPress sites
- Custom Post Types and Broken Permalinks
- The first post appears twice
- how to call recent post content in a loop ( only the content before read more tag)
- Find post tags words in post content and link them to tag URLs
- How can I filter the post of a CPT by taxonomy Term in admin meta-box dropdown?
- Show Posts By Custom Field
- Hide title in Merlin Theme on posts and pages only
- Custom plugin to get related posts by category
- is_archive() not working on selected “Posts page”
- Relative Image Urls in Posts are starting from root – Not from WordPress Address (URL) at General Settings
- How to associate media with a post?
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- My posts section for logged in user
- Preview own posts if logged in
- Pagination for custom query won’t let me back on page 1
- thumbnail image path and file path for gallery thumbnail images
- Displaying warning if no featured image has been set – Post Editor
- How to highlight most recent posts in a list
- wordpress show category link instead of post link [closed]
- CSS – Change height of Storefront / WooCommerce product categories, but not products
- How to add a new page that will function as a separate blog/news article page
- How to set value in Query Loop?
- Display content from specific category
- Batch Scanning and Deleting Empty WordPress Posts
- WordPress Custom Post type csv exporter