✨ Solution
I’m not sure this is the most efficient way to use rest_post_dispatch (documentation) for this purpose (maybe overkill but I didn’t found other way).
It works as expected.
add_filter("rest_post_dispatch", "rest_customize_result", 10, 3);
function rest_customize_result(
WP_REST_Response $result,
WP_REST_Server $server,
WP_REST_Request $request
) {
if ( $request->get_route() === "/jwt-auth/v1/token"
&& $result->get_status() === 403 ) {
$data = $result->get_data();
$data["code"] = "jwt_auth_failed";
$data["message"] = __("Invalid Credentials.", "theme");
$result->set_data($data);
}
return $result;
}
Related Posts:
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- How can I see all the actions attached to an “add_action” hook?
- Where is the best place to use add_filter
- How to only hook on Single.php after content?
- How can I log a user out of WordPress before the page loads?
- Which hook callback has priority if both plugin and theme use the same hook?
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Use external link in the add sub menu
- Very stubborn wp_register_script / add_action vs remove
- How to prepend to the_title for admin-side plugin’s use
- do_action and hook methods
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- Creating search filter through plugin
- What is the purpose of $merged_filters?
- Reposition Woocommerce Message
- How to remove xmlns on language_attributes()?
- add_query_arg not working
- How to Use Parameters with a Do_Action Function Within PHP Tags
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- How to stop or remove an action being called inside a function of an extended class
- Automatically add attributes to woocommerce product?
- wordpress plugin is not activating from widget
- How to get the element ID from new menu list that added with add_filter()?
- How to check current user before all actions and filters?
- Get Time Taken By Each Action Hook in WordPress
- Removing an action from wp_footer called in a class that’s inside a bigger class
- Plugin developer automated documentation
- Is there a hook to Intercept al urls from a webpage and redirect to a page
- WordPress user account activation
- External Script Using WP – Hooks / Actions Not Working?
- Redirect to another page using contact form 7? [closed]
- What is @Action in WordPress?
- Is there a way to figure out which action/filter invoked a function?
- How passing values to construct function with Actions?
- add_action into another add_action not working
- Using add_action before add_filter on a plugin?
- Check if variable is set in filter
- remove_action not removing add_action from constructor
- Basic function call on init failing
- Editing wp-config.php
- Are there action hooks for comments?
- Change text string in a plugin
- WordPress: Add custom add_filter for custom functions
- Override a Plugin Function
- How to use add_action for multiple instances of the same class
- How to hook into action/filter call
- Cannot access empty property error in Advanced Access Manager
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- Edit post image attributes on fly?
- Use a hook or filter, or overwrite this Gamipress function?
- How to convert Currency from USD to other IP Based currency in Php function
- Redirect to a page while maintaining search query parameters without causing an infinite loop
- Hooking into the HTML header container
- 500 Internal server error wp_handle_upload_prefilter
- How to Unhook actions/filters in within Class in plugin
- Nested Actions and Filters
- Use action, filter, or hook to append HTML to WordPress plugin function
- Get post content inside plugin class method
- Ajax call to php function doesn’t work PHP code
- Remove action added in plugin class from theme
- Show custom taxonomy in theme
- Creating Admin Submenu Page via Class Method
- Help needed with woocommerce (wc stripe) filter
- What action or filter can I use to change all the html returned from server for a page?
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Passing a parameter to filter and action functions
- plugins_loaded action is not working properly
- Plugin Hook: Get posts
- change output location of plugin function using a custom hook
- Filter for modifying image on upload
- Which filters or actions involve with index page for plugin?
- add query string to all pages after user logged in
- Which action/filter can i use for a Member Plugin [closed]
- add_action() not working for admin
- is_singular() in mu-plugins not working
- Consuming an external API in WordPress?
- How to Loop Plugin Option Field Set?
- Failed to invoke other hook from the init hook
- Create plugin that works in background
- Checking for user role in a custom plugin
- Is it possible to remove this action? (as it’s added just before it’s called)
- There’s some way to add a wrapper around posted images?
- jQuery function didn’t work in my plugin
- Adding an Options Page to a Plugin
- How do I “get the next 10 posts after post_id == x”?
- Inserting above the comment template
- How do I create a filter feature on WordPress? [closed]
- Customizing NEXTGEN Gallery To link images to pages
- Ability to automatically redirect a URL
- Passing Page ID used in Meta Box Creation to JavaScript
- Check filter defined or not?
- Any idea how to get something like this to work? [closed]
- Looping the data from WordPress database using foreach
- Rename a folder via HTML POST request
- Plugin Breaking WordPress Login
- How can I allow for the password protect feature to allow visitors to enter any number at all?
- Adding a script & php to functions.php