[wp-trac] [WordPress Trac] #25786: Using custom_fields with wp.newPost does not add meta on clean WordPress installs.
WordPress Trac
noreply at wordpress.org
Thu Oct 31 03:52:30 UTC 2013
#25786: Using custom_fields with wp.newPost does not add meta on clean WordPress
installs.
--------------------------+-----------------------------
Reporter: timgws | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: XML-RPC | Version: 3.7.1
Severity: major | Keywords: dev-feedback
--------------------------+-----------------------------
When using wp.newPost with WordPress' XML-RPC on a clean install of
WordPress 3.7.1, the meta fields fail to be added.
This is due to checks inside `class-wp-xmlrpc-server.php`.
When the custom_fields struct is used in a new WordPress post using
wp.newPost, $this->set_custom_fields is called with the value of
custom_fields, along with the posts id.
`current_user_can` is then called asking for the `add_post_meta` role.
This check returns false for all default role types, including
Administrator.
The only way that I have been able to resolve it so far is to run the
following code inside a WordPress plugin first:
$role = get_role( 'administrator' );
$role->add_cap('edit_post_meta');
$role->add_cap('delete_post_meta');
$role->add_cap('add_post_meta');
After running this code, posts can finally be added with custom meta data.
Is there something that I am missing? There does seem to be code inside
the `map_meta_cap` function inside `capabilities.php` to map this
capability to edit_post, but this mapping code does not seem to run when a
new post is being added or edited.
This results in all attempts to add meta values (such as post specific
meta data for plugins) to fail.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/25786>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list