WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Update Page Button (8 posts)

  1. jankowski
    Member
    Posted 8 months ago #

    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!

  2. mindctrl
    Member
    Posted 8 months ago #

    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.

  3. jankowski
    Member
    Posted 8 months ago #

    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!)

  4. mindctrl
    Member
    Posted 8 months ago #

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

  5. jankowski
    Member
    Posted 8 months ago #

    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?

  6. mindctrl
    Member
    Posted 8 months ago #

    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.

  7. jankowski
    Member
    Posted 8 months ago #

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

    Thank you for your help!

  8. jankowski
    Member
    Posted 8 months ago #

    Fixed with wp_set_current_user()

Reply

You must log in to post.

About this Topic