Make WordPress Core

Opened 13 years ago

Last modified 3 years ago

#15230 new enhancement

Action hook before the inserting post into the database

Reported by: johnnypea's profile johnnypea Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: dev-feedback has-patch
Focuses: Cc:

Description

Something like

do_action( 'pre_post_insert', $data, $postarr );

added to wp_insert_post function right after the "else" statement on line 2501 in .../wp-includes/post.php

Attachments (4)

post.php (165.4 KB) - added by johnnypea 13 years ago.
post.diff (395 bytes) - added by kapeels 13 years ago.
Patch instead of the file attached.
15230.diff (621 bytes) - added by pareshradadiya 9 years ago.
Patch updated
pre_post_insert.patch (674 bytes) - added by pbearne 8 years ago.
refesh

Download all attachments as: .zip

Change History (23)

#1 follow-up: @nacin
13 years ago

  • Keywords needs-patch reporter-feedback added; hook action post insert removed

Use case? Also, real patch please.

#2 in reply to: ↑ 1 @johnnypea
13 years ago

Replying to nacin:

Use case? Also, real patch please.

For example in case I want to check if such a post exists in the database before inserting it - almost every data inserted into the database has its "pre_insert_hook" so why posts not?. I know there is this wp_insert_post_data filter where can I do this check but anyways it is not the action hook.

@johnnypea
13 years ago

#3 @nacin
13 years ago

  • Keywords reporter-feedback removed
  • Milestone changed from Awaiting Review to Future Release

Please post a patch, versus a file.

@kapeels
13 years ago

Patch instead of the file attached.

#4 @kapeels
13 years ago

  • Keywords has-patch added; needs-patch removed

#5 @kapeels
13 years ago

  • Cc kapeels added
  • Keywords has-patch removed

#6 @kapeels
13 years ago

  • Keywords dev-feedback added

#7 @SergeyBiryukov
11 years ago

#22165 was marked as a duplicate.

#8 @sirzooro
11 years ago

  • Cc sirzooro added

Related: #18692, #18266

#9 @nacin
11 years ago

#22165 was marked as a duplicate.

#10 @nacin
11 years ago

#22165 was marked as a duplicate.

#11 @thomask
11 years ago

  • Version 3.1 deleted

Please look at #22165 with real live use case. In http://core.trac.wordpress.org/ticket/22165#comment:3 there is another option how this can be solved.

Please change version to 3.4.2 - it is not possible for me now.

#12 @markoheijnen
11 years ago

  • Version set to 3.1

The version is where it is implemented and not the latest version it occurs.

#13 @SergeyBiryukov
11 years ago

  • Component changed from Plugins to Post Types

Related: #21450

#14 @pareshradadiya
9 years ago

  • Keywords has-patch added

I'm working on membership plugin and every user has a certain number limit on add new post. I want to check total post count by the author before data has been save in the database but at the moment wp_insert_post does not have a pre_post_insert hook. It would be nice to add this hook in core.

@pareshradadiya
9 years ago

Patch updated

#15 @pbearne
8 years ago

Yes please

Otherwise you need to exit out of filter to stop the save :-)

Last edited 8 years ago by pbearne (previous) (diff)

@pbearne
8 years ago

refesh

#16 @pbearne
8 years ago

  • Keywords needs-refresh added

#17 @pbearne
8 years ago

  • Keywords needs-refresh removed

#18 @websupporter
7 years ago

+1 for this

Use case: Make sure whatever happens, certain phrases will never be in a post. Do not care about whether they enter through a plugin using wp_insert_post() in some way or through the editor, or through the REST API or whatsoever.

Using pre_post_insert would help me to easier solve this request.

#19 @SergeyBiryukov
3 years ago

#53178 was marked as a duplicate.

Note: See TracTickets for help on using tickets.