Topic: Use hook/custom endpoint after post creation – WS Form

My Account

Forums

Forums General Use hook/custom endpoint after post creation

Viewing 2 reply threads
  • Author
    Posts
    • #36958
      cubetech
      Participant

      Hi there

      Anyone knows a way how I can create a post based on the submitted form and then fire a hook/action and passing the newly created post id to it?
      Background: I have to create a post but after this I have to update some fields in the newly created post – ofc I can check for the latest created post but this is not that secure 😀

      Thanks
      Christian

    • #37099
      cubetech
      Participant

      Okay looks like I found the solution by myself 🙂

      Based on the example here https://wsform.com/knowledgebase/handling-submit-data-with-your-own-code/ I created a function which simply checks for existence of a custom property:

      function SendNotifications($form, $submit) {
        if (property_exists($submit, 'post_id')) {
          $newlyCreatedPost = $submit->post_id;
        }
        return $submit;
      }

      If there is a post_id I can then do whatever I want with it 🙂

    • #37248
      Mark Westguard
      Keymaster

      Great!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.

Login