HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Delete discussion programmatically

What is the best way to do this?

Thanks

Comments

  • phreakphreak Vanilla*APP (White Label) & Vanilla*Skins Shop MVP
    edited November 2019

    Hi @rloyola

    You will need a custom plugin for that.

    I am not sure maybe the “Archive” function still exists in Vanilla. But I guess that is not what you want to achieve.

    • VanillaAPP | iOS & Android App for Vanilla - White label app for Vanilla Forums OS
    • VanillaSkins | Plugins, Themes, Graphics and Custom Development for Vanilla
  • R_JR_J Ex-Fanboy Munich Moderator

    The cleanest way is to use the models methods: DiscussionModel::instance()->deleteID will do the trick


       /**
        * Delete a discussion. Update and/or delete all related data.
        *
        * Events: DeleteDiscussion.
        *
        * @param int $discussionID Unique ID of discussion to delete.
        * @param array $options Additional options to control the delete behavior. Not used for discussions.
        * @return bool Always returns **true**.
        */
       public function deleteID($discussionID, $options = []) {
    
    



    rloyola
  • Maybe you would like to use the Vanilla Forums API, in Python you would request a http DELETE using requests to `https://[yousite.com]/api/v2/discussions/[discussion_id]`

    I think (obviously) you will need the authorizations for the request to be accepted, I never tinkered with the api yet, but I think you can manage to do it with this example (or translate it to whichever language you use)

    #!/usr/bin/env python3
    
    import requests
    
    ENDPOINT = "https://[yousite.com]/api/v2/discussions/[id]"
    
    x = requests.delete(ENDPOINT)
    
    print(x.text)
    
    

    Also, for security reasons maybe you would like to configure your webserver to restrict requests only for you specific IP address.

    rloyola
Sign In or Register to comment.