# How to use deploy_after hook?

**URL:** https://discourse.roots.io/t/how-to-use-deploy-after-hook/20811
**Category:** trellis
**Created:** 2021-05-20T00:22:47Z
**Posts:** 3

## Post 1 by @g000m — 2021-05-20T00:22:47Z

I have a similar agenda to this [thread about theme security](https://discourse.roots.io/t/bedrock-default-themes-security-exploit-how-to-remove-them/18651).

I want to delete the themes, and I’m trying to understand how to use hooks.

I have a task that works:

```
- name: Delete WP themes
  ansible.builtin.file:
    path: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/web/wp/wp-content/themes/"
    state: absent
  with_dict: "{{ wordpress_sites }}"
```

I initially put it in build-after, and realized it was running too early. In the [Deployments doc](https://roots.io/docs/trellis/master/deployments/#hooks), the final hook listed is deploy\_after. I’m seeing that the convention is to drop deploy\_ from the filename of the hook, so this would be after.yml?

I put my task into after.yml (also tried deploy\_after.yml) and tried putting it both in hooks folders:

- trellis/deploy-hooks/
- trellis/roles/deploy/hooks/

The task doesn’t run.

I see “Check if deploy\_after scripts exist” in trellis/roles/deploy/tasks/main.yml exists, but due to my lack of familiarity with Ansible, I’m not clear what’s missing.

Thanks

---

## Post 2 by @strarsis — 2021-06-09T14:34:26Z

Discussion and solutions for removing the default themes from WordPress core package:

> [@Remove Default WP Themes From Core](https://discourse.roots.io/t/remove-default-wp-themes-from-core/3611/14):
>
> PS, if you want to also remove them from sites that already have them downloaded, then you would need to use not the post-root-install-package callback, but also the post-update-cmd. So in that case, rather than the code in the Github PR, the Scripts section of your composer.json would look something like this "scripts": { "post-root-package-install": ["php -r \"copy('.env.example', '.env');\"", "composer run remove-old-wp-themes"], "post-update-cmd": [ "composer run remove-old-wp…

---

## Post 3 by @system — 2021-07-01T00:22:47Z

This topic was automatically closed after 42 days. New replies are no longer allowed.
