$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>admin - How to save edited post when submitting form|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

admin - How to save edited post when submitting form

matteradmin8PV0评论

I have added a custom button(via form in html) on my WooCommerce edit product(same as WordPress edit past I think) page. When this button is pressed, my php code will parse the post content. The problem is that if I edit the post content, and do not first click the standard "Update" button, my edited content is lost. How can I add the standard WordPress "Update" button functionality to my custom form button?

This is my form I added, using the "add_meta_box" action:

<form method="post" action="">
<div>
<input type="submit" name="mxUpldImg" class="button-primary" alue="Upload Mx Img" />
</div>
</form>

I then check for my post using the "admin_init" action.

I have added a custom button(via form in html) on my WooCommerce edit product(same as WordPress edit past I think) page. When this button is pressed, my php code will parse the post content. The problem is that if I edit the post content, and do not first click the standard "Update" button, my edited content is lost. How can I add the standard WordPress "Update" button functionality to my custom form button?

This is my form I added, using the "add_meta_box" action:

<form method="post" action="">
<div>
<input type="submit" name="mxUpldImg" class="button-primary" alue="Upload Mx Img" />
</div>
</form>

I then check for my post using the "admin_init" action.

Share Improve this question asked Feb 4, 2019 at 6:08 davidaudavidau 1
Add a comment  | 

1 Answer 1

Reset to default 0

What are you doing in the parsing function of the post content? You can do the same thing on the trigger of the standard update button to avoid data loss.

Please use the save_post hook to perform your function on the click of the standard update button. Please see the below link for documentation of save_post hook. https://codex.wordpress/Plugin_API/Action_Reference/save_post

Post a comment

comment list (0)

  1. No comments so far