WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 2 years ago

#14283 closed enhancement (fixed)

Add a new action, fired when a post is added via XMLRPC

Reported by: simonwheatley Owned by: westi
Milestone: 3.4 Priority: normal
Severity: normal Version:
Component: XML-RPC Keywords: 3.2-early has-patch commit
Focuses: Cc:

Description

Currently when you want to manipulate a new post which has been added over XMLRPC after the attachments have been added, there is no action to neatly hook. (Attachments are assigned to their parent via $wpdb queries, and no further actions or hooks appear to be triggered after the attachments have been added.) This patch suggests a new hook which fires at the end of the mw_newPost method.

Not sure about the name "xmlrpc_post_new_post" (post new post is meant to refer to "after a new post").

If this patch is acceptable perhaps it's worth adding similar actions to mw_editPost, 'mw_newPage, and mw_editPage`, etc.

Attachments (2)

new_xmlrpc_new_post_action.diff (506 bytes) - added by simonwheatley 4 years ago.
Adds a new action to XMLRPC after a new post has been added
14283.diff (1.3 KB) - added by ericmann 3 years ago.
Add success hooks to post/page calls.

Download all attachments as: .zip

Change History (9)

simonwheatley4 years ago

Adds a new action to XMLRPC after a new post has been added

comment:1 nacin3 years ago

  • Milestone changed from Awaiting Review to Future Release

Joseph?

comment:2 westi3 years ago

  • Keywords needs-patch 3.2-early added; has-patch removed
  • Owner set to westi
  • Status changed from new to accepted

This sounds reasonable.

We should probably add hooks at the end of all the relevant XML-RPC functions for posts/pages.

Naming scheme and format something like:

do_action('xmlrpc_call_sucess_blogger_newPost', $post_ID, $args);

Moving to 3.2-early

comment:3 ericmann3 years ago

  • Keywords changed from needs-patch, 3.2-early to needs-patch 3.2-early

I like the idea, so I'm submitting a patch that adds an action hook to:

  • wp.deletePage
  • blogger.newPost
  • blogger.editPost
  • blogger.deletePost
  • mw.newPost
  • mw.editPost

These are all the relevant post/page methods where this kind of hook makes sense. The wp methods for editing and creating posts just direct to mw_editPost() and mw_newPost() anyway, so they'll end up using the same hooks.

I'm using westi's proposed schema as well:

do_action( 'xmlrpc_call_success_{method name}', $post_ID, $args );

We might want to consider adding similar hooks for comments and media calls, but that would be another ticket ...

ericmann3 years ago

Add success hooks to post/page calls.

comment:4 ericmann3 years ago

  • Keywords has-patch added; needs-patch removed

comment:5 ericmann3 years ago

Related: #17109

comment:6 westi2 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 3.4

Looks good.

comment:7 westi2 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In [20158]:

XMLRPC: Add some xmlrpc_call_success_* actions to some of the post creation/deletion calls. Fixes #14283 props ericmann, simonwheatley.

Note: See TracTickets for help on using tickets.