Title: Running a function when a 3rd party php function runs
Last modified: June 18, 2019

---

# Running a function when a 3rd party php function runs

 *  [Felty](https://wordpress.org/support/users/felty/)
 * (@felty)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/running-a-function-when-a-3rd-party-php-function-runs/)
 * I’ve been looking over add_action() and do_action() as this seems like what I
   need, but I need a bit more information.
 * So let’s say I wrote a discord hook bot that can run based on information sent
   to it… This is no issue.
 * For example:
 * However, I want to latch on to 3rd party plugin and every time that function 
   is executed, then have the bot say something in Discord.
 * Does it require me to or the original author to have added the function to add_action()?
 * So let’s say I have another plugin that I made… with
 *     ```
       function origin_func($args)
       {
        //stuff
       }
       ```
   
 * Do I need to:
 *     ```
       add_action( 'origin_function_action' 'origin_func')
       ```
   
 * In either the original or new and then in the new discord plugin…
 * How to I check to see if that custom action is run and then have the new one 
   run?
 * Thanks!
    -  This topic was modified 6 years, 11 months ago by [Felty](https://wordpress.org/support/users/felty/).
    -  This topic was modified 6 years, 11 months ago by [Felty](https://wordpress.org/support/users/felty/).

Viewing 1 replies (of 1 total)

 *  [Cory](https://wordpress.org/support/users/corypina/)
 * (@corypina)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/running-a-function-when-a-3rd-party-php-function-runs/#post-11650393)
 * The third-party plugin needs to include `do_action`. E.g.:
    `do_action('third_party_hook');`
 * In your own code, you use `add_action`:
    `add_action('third_party_hook', 'your_function');`

Viewing 1 replies (of 1 total)

The topic ‘Running a function when a 3rd party php function runs’ is closed to new
replies.

## Tags

 * [add_action](https://wordpress.org/support/topic-tag/add_action/)
 * [do_action()](https://wordpress.org/support/topic-tag/do_action/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [Cory](https://wordpress.org/support/users/corypina/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/running-a-function-when-a-3rd-party-php-function-runs/#post-11650393)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
