Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.

Delete discussion programmatically

What is the best way to do this?

Thanks

Comments

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

    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 Cheerleader & Troubleshooter 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.