Title: redirection_create_redirect not available
Last modified: November 21, 2024

---

# redirection_create_redirect not available

 *  Resolved [sipw](https://wordpress.org/support/users/sipw/)
 * (@sipw)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/redirection_create_redirect-not-available/)
 * I’m attempting to programmatically create redirects. While hooks such as `redirection_request_url`
   and `redirection_url_source` are firing correctly, the primary function `redirection_create_redirect`
   is not available during runtime, even after the plugin has fully initialised.
   Am I missing something?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/redirection_create_redirect-not-available/#post-18151534)
 * Without knowing what you are doing I can’t say if you are missing anything. `
   redirection_create_redirect` is fired every time a redirect is created using 
   the Redirection code.
 * If you are programmatically trying to create redirects why are you using hooks?
   There’s an API that can create redirects directly.
 *  Thread Starter [sipw](https://wordpress.org/support/users/sipw/)
 * (@sipw)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/redirection_create_redirect-not-available/#post-18152038)
 * Thanks for the swift response!
 * Initially, we explored using hooks because we assumed they were the intended 
   way. They offered potential advantages such as better performance, no need for
   authentication, and no additional HTTP requests. Plus, we referred to your hooks
   documentation, which seemed to suggest they might be appropriate.
 * We’re creating redirects for URLs that are removed during an API call. When these
   URLs are no longer available in the API, we need to create redirects to a fallback
   page.
 * However, we’ve since shifted to using the REST API. The issue we’re facing with
   the API is persistent timeouts (`cURL error 28`), even with extended timeouts
   and valid authentication. The `/wp-json/redirection/v1/redirect` endpoint doesn’t
   respond within the allocated time, despite other REST API functionality on the
   site working fine. We’re trying to determine if this is a plugin-specific issue,
   server configuration problem, or something else.
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/redirection_create_redirect-not-available/#post-18152065)
 * The hooks are just WordPress action and filter hooks. They are fired when you
   do something in Redirection and allow you to customise the default behaviour.
 * The API is used by the plugin itself, so if it is working fine then the API is
   working fine and the problem is elsewhere.
 * Also, you can call API endpoints internally within WordPress using one of the
   built-in API functions. If your code is running in WP there is no need to make
   an external request.
 *  Thread Starter [sipw](https://wordpress.org/support/users/sipw/)
 * (@sipw)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/redirection_create_redirect-not-available/#post-18152321)
 * Ok many thanks. The only issue we’re hitting now is with passing the action_data–
   it’s being saved as null. Redirections are created, just obviously with no target
   url.
   {“url”: “/test-source”,“action_data”: “/test-target”,“match_type”: “url”,“
   action_type”: “url”,“group_id”: 1,“enabled”: true}
 *     ```wp-block-code
       {"id": 6467,"url": "/test-source","match_url": "/test-source","match_data": {"source": {"flag_query": "exact","flag_case": true,"flag_trailing": true,"flag_regex": false}},"action_code": 301,"action_type": "url","action_data": null,"match_type": "url","title": "","hits": 0,"regex": false,"group_id": 1,"position": 0,"last_access": "-","enabled": true}
       ```
   
 *  Thread Starter [sipw](https://wordpress.org/support/users/sipw/)
 * (@sipw)
 * [1 year, 6 months ago](https://wordpress.org/support/topic/redirection_create_redirect-not-available/#post-18154147)
 * Got it. The `"action_data"` field must be an object containing a `"url"` key,
   not just a string.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘redirection_create_redirect not available’ is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [sipw](https://wordpress.org/support/users/sipw/)
 * Last activity: [1 year, 6 months ago](https://wordpress.org/support/topic/redirection_create_redirect-not-available/#post-18154147)
 * Status: resolved