• Resolved jankowski

    (@jankowski)


    What WordPress function is called when the “Update Page” button is clicked, and in what file can I find that definition?

    Thanks for any help, apologies if this isn’t the proper forum!

Viewing 7 replies - 1 through 7 (of 7 total)
  • wp_update_post does the update stuff. If you’re looking to do something when a post is saved, it’s probably better to use the save_post hook.

    Thread Starter jankowski

    (@jankowski)

    Thanks, tried wp_update_post, didn’t work quite as I had hoped. To be a bit more specific about my problem, I’m manually creating a page using a PHP command line script, and I’m trying to have certain privacy settings from the plugin User Access Manager be applied to that page. With just my script, the settings are not properly applied. However, when I go onto the WordPress editor on my site and simply click the “Update Page” button for the page without doing anything else, the settings suddenly activate. I’m sure there’s some function within the plugin source code that would help, but it’s quite an extensive set of files, and I’m just trying to have the page update itself from the PHP script as a bit of a shortcut. When I tried wp_update_post() in different parts of the script, nothing new happened.

    Do you know if any other functions are called when the button is clicked? (Thank you for the response!)

    wp_update_post calls wp_insert_post. The previously mentioned save_post hook runs, and is commonly used to do things during post events.

    Thread Starter jankowski

    (@jankowski)

    So if I’m using wp_insert_post already in my code, I should try to find where, in the plugin source code, the author uses add_action('save_post, etc. etc.) and try to use that function?

    Yes, that’s a good start. You’ll likely have to bootstrap the plugin to get access to all the data it needs to do the function(s). This can get kinda tricky. I suggest reaching out to the plugin author to see if he has any recommendations for doing this.

    Thread Starter jankowski

    (@jankowski)

    Okay, thanks! Yeah, he’s been okay about getting back to me but hasn’t responded lately.

    Thank you for your help!

    Thread Starter jankowski

    (@jankowski)

    Fixed with wp_set_current_user()

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Update Page Button’ is closed to new replies.