Just a guess: Your regular expression 'verify/(?<voucher_code>)'
is not correct. Have a look here. They are using e.g. (?P[a-zA-Z0-9-]+)
there’s a P inside.
Another reason could be that you are missing a / before the verify. Try this:
function register_voucher_endpoint() {
register_rest_route(
'voucher',
'/verify/(?P<voucher_code>[a-zA-Z0-9-]+)',
array(
'methods'=> 'POST',
'callback'=>'verify_voucher'
));
}
[a-zA-Z0-9-]
defines the regular expression group for this endpoint.
To answer question nr. 2: check the global $_POST
array. There you should have an voucher-code
entry which you can access with $_POST['voucher-code']
.
I’m not 100% sure my answer is correct.
Related Posts:
- Need logged in users returing to site redirected to a separate page
- How to let a single post have its own domain name
- Redirect members to custom page upon logging in through WP admin
- Redirect to requested page after (custom) login
- Hide Login information in Account settings in Buddy Boss
- Turn off redirect to canonical domain (or host website on any hostname)
- Search result page redirect ex.com/?s=searchterms to ex.com/searchterms
- How To Load an HTML File As A WordPress Page (With No 301/No Redirect)
- How do I create a root link in wordpress to a PDF file?
- Restrict content access to logged in users
- Showing different pages depending on a cookie value
- Block direct access to thank you pages
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Allow arbitrary text after page URL
- Redirect all pages to the custom login page except for the registration page
- Redirection after Category Change for Custom Structure
- Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
- Any post install tips after installing WordPress 3.0.1?
- Customizing the Subject Field in WordPress’ Notification Emails?
- How to move wp-content (or uploads) outside of the WordPress directory
- How can I integrate pages written in something other than PHP?
- Maintaining synced staging/production WP sites
- WordPress Multi Site Best Practice
- Sub posts and non unique post_name
- Custom field values in permalink
- Custom protected password page with ACF
- Page load requires a trailing “/” [closed]
- How to instantly delete posts/pages permanently?
- dynamic external javascript generated using php
- Show Custom Taxonomy Slug(s)?
- How to re-arrange media uploaded using : media_handle_upload() as per year / month
- How could we customize the all posts page in the admin panel?
- What’s the proper way to use a custom table? [closed]
- How to retrieve the value stored in a multi-dimensional array and SUM the entries?
- Adding Pagination on a Custom Author Page
- How can I get the page url slug when ‘post_name’ returns an id?
- Woocommerce Product page edit
- Integrate WordPress into existing website
- How can I use get_bloginfo(‘admin_email’) in a custom PHP file?
- CSS to remove “comments count” icon from main page [closed]
- What’s wrong with Customizing new user notification email by add_filter?
- Automatically Update Woocommerce Prices [closed]
- Multiple Tinymce/wp_editor in WordPress >4.8
- How to provide a demonstration of WordPress for new customers
- CPT Loop with ACF and passing ID between Loops
- Showcase elementor templates
- Add clickable arrows to parent menu items with children elements e.g. with
- Display User ID instead of Name or Username
- Woocomerce custom billing address fields display in order details [closed]
- Bind JS event to WordPress control customizer
- No shipping method has been selected [closed]
- How can I setup up an a pre-populated pdf based on what was entered? [closed]
- Get rid of title from static front page
- Make custom page look exactly as homepage
- Organizing the position of widgetized areas in the backend
- $wpdb->insert running multiple times?
- Get wordpress taxonomy slug name(s) to use as div class
- Why does my Posts page only show a single post when using Thematic?
- Specific colours for wordpress author ids
- How do I list custom taxonomy terms with the links?
- How to unpixelate logo?
- Open “Visit site” in a new window?
- Remove header title form page through CSS [closed]
- What’s the right way to share data between widgets?
- custom css and javascript not working on page defined as template?
- Importing specified data/field
- Missing current_page_item in custom menu
- Attach File Funcion for Common people
- How to retain visual breadcrumbs w/ tricky URL structure? Custom post template?
- Mimicking admin panel menu from wordpress 3.0.1
- query variables for custom taxonomies
- How to get Previous Visited Page Information
- Adding overlay search to wordpress using add action/filter
- wordpress custom fields loop
- Custom admin menu items
- How do I add a dropdown menu to a form?
- Taxonomy template is not reading
- Conflict between Yoast SEO and my custom theme
- POST 429 Error when trying to place more than 20 images into post at once
- Issue with navigation bar in child theme
- Send email notification when post type product is publish from pending status
- WordPress Customizer: Check for value of CSS selector and replace it
- How to add custom Author Info Box to blog posts “only” and NOT custom post templates
- Bio comes up when the visitor clicks on a picture
- How to find and replace (or add) specific word in a specific category?
- Creating a Treeview Listing of a Directory
- WooCommerce – Adding custom HTML to specific product pages
- How do I move my sites to a child theme without loosing customisation?
- Displaying all Custom fields on post except some
- How to create new page can get custom field other post in wordpress
- How to appoint different users to different pages?
- insert autofocus in a custom taxonomy form
- display my pages html
- Is there a way to hide a user’s posts from their Activity feed?
- customize footer widgets area
- Accessing + retrieving custom database in WordPress
- updated permalink structure on localhost does not work
- Word Press Theme Customiser and Child theme Function.php
- Security Issues with custom user role or changing core role capabilities?
- adding new html css to wordpress section from codepen [closed]