Modify publish/update button behavior on wordpress add/edit post page?

39
March 15, 2019, at 01:00 AM

I need to open modal window with "additional" form hitting on publish/update button. Then admin will have a possibility to fill additional fields and click update button in the modal. These fields are independent from this post so I need so to save them in particular table in the database.

I tried to modify onclick event for publishing button via jQuery. But how can I manually send these two forms after clicking on update button in the modal window. I know about wp_insert_post_data whick works before post added to database so I'd like to write something like that:

add_filter('wp_insert_post_data', 'do_not_create_post', '99');
function do_not_create_post($data) {
    $data['post_status'] = 'pending';
    add_filter('redirect_post_location', 'my_post_redirect_filter', '99');
  return $data;
}
function my_post_redirect_filter($location) {
  remove_filter('redirect_post_location', __FILTER__, '99');
  return add_query_arg('open_modal', 1, $location);
}
add_action('admin_notices', 'my_post_admin_notices');
function my_post_admin_notices() {
  if (!isset($_GET['open_modal'])) return;
  if ($_GET['open_modal'] == 1) {
    echo '<script> which opens modal window';
  }
}

Is there any easier way? How can I insert post manually to the database after filling the modal and then save additional data? Generally I need a way how to modify edit/add post pages properly in more beautiful way.

READ ALSO
how to slov this function for skip validation [on hold]

how to slov this function for skip validation [on hold]

this function for validation license code, any one can help me ?? i want to hack this function for skip this step without any problem**

17
crud edit button only showing last variable

crud edit button only showing last variable

I am creating my first php app and running into an issue on how I should try and edit a sql entryI was planning on trying to get a modal window to pop up in order to edit

22
String type casing in php, is it string or String?

String type casing in php, is it string or String?

What is the official name for the php string type?

12