Internally, WooCommerce uses WordPress’ wp_safe_redirect()
which does not allow redirects to external hosts. In order to get around this, we must add our desired host to the whitelist. The whitelist can be modified using the allowed_redirect_hosts
which has been demonstrated below:
/**
* Adds example.com to the list of allowed hosts when redirecting using wp_safe_redirect()
*
* @param array $hosts An array of allowed hosts.
* @param bool|string $host The parsed host; empty if not isset.
*/
add_filter( 'allowed_redirect_hosts', 'wpse_allowed_redirect_hosts', 10, 2 );
function wpse_allowed_redirect_hosts( $hosts, $host ) {
$hosts[] = 'example.com';
return $hosts;
}
Use the code above along with your original code (customizing the host as needed) to allow WooCommerce users to be redirected to an external domain after completing the registration process.
Related Posts:
- WooCommerce Registration redirect based on page ID
- How to check if is in cart page? [closed]
- Remember page before login page, redirect to that page after login
- WooCommerce lost password reset flow not working with SendGrid (redirect loop)
- Username field is not shown in Woocommerce’s registration contact form
- Import products to WooCommerce by CSV page won’t open [closed]
- Woocommerce Login Redirect not working [closed]
- Redirect user after login through woocommerce login page to page with his/her username?
- Which hook should I use to capture $_POST(‘password’) via profile update and password reset
- Force User Registration before visitng Checkout Page
- Register a new user on wooCommerce using Rest API
- Allow WooCommerce existing customers to checkout without being logged in [closed]
- Redirect customer to login page (with other signup plugin) if user not logged in when proceeding to checkout
- Auto generate user email while registration
- Woocommerce – Want to block a user agent from accessing specific product pages
- How to – proper WordPress 301 redirects?
- Woocommerce, prevent login after registration and redirect to custom URL
- Woocommerce check if email already created order recently [closed]
- Redirect no product url’s to static url
- Block Disposable Emails on Woocommerce Registration
- Clients with empty username are not receiving request new password email
- WooCommerce get_author_posts_url() – Author URL redirecting to shop base
- Woocommerce Register Error
- Make e-Mail optional on Woocommerce sign up
- Assign user role by text field in WordPress (Woocommerce) [closed]
- Impossible to create a new WooCommerce customer using Rest API
- Registration roles
- Is it ok to 301 redirect product-category pages to custom pages?
- How to send Woocommerce Customer Details (Name, Email and Phone Number) to Admin upon signup
- WooCommerce and ACF: How to Redirect Upon Add to Cart – Partially Working Example
- wordpress site auto redirect to another site when I enable woocommerce
- Redirect After Registration on Specific Link
- Custom Registration Fields woocommerce
- mydomain.com/wp-login redirects to wordpress.com/wp-login
- WooCommerce shop, my account, cart every page redirect to home page [closed]
- Change WooCommerce registration form/way?
- DatePicker in Woocommerce (My Account) Registration [closed]
- Remove login fields from /customer-account page [closed]
- add_filter to modify woocommerce_cart_item_name hyperlink
- How to get rid of the hover zoom in WooCommerce single products
- How do I display certain products via their category on a section of a page using PHP?
- Display orders instead of woocommerce my account dashboard for logged in users [closed]
- Detect whether a page is a product subcategory page?
- Programmatically change Payment Methods WooCommerce
- pre_get_posts with WooCommerce Shortcode Query
- WooCommerce is slow with many categories [closed]
- How to remove recurring totals information for a particular subscription product? [closed]
- WordPress codex: apply_filters – clarification on creating a new hook on the fly. How do we use it?
- woocommerce change order statuses count for specific role
- global $post; in WooCommerce
- Woocommerce template single-product.php in theme folder not working
- WordPress ‘on behalf of’ email
- Display description on cart page
- Problems adding in-store product managers
- differentiate hooks and filters on the same page [closed]
- WooCommerce Product URL re-writing
- Automatically running Scheduled Actions
- Hook to use when customer placing order
- Calculate tax on sales price excluding discount [closed]
- One file for all virtual, downloadable product variations [closed]
- WooCommerce – Global $product is returning value null
- Remove “?add-to-cart=product-id” from Add to Cart URL when on the Cart page
- How to show total amount on woocommerce?
- Disable Order Review Page when the id product
- Set both meta_query and tax_query using wp_query->set
- Protecting WooCommerce Customizations with Update
- Setting WooCommerce SKU programmatically [closed]
- How to edit mobile view of my wordpress website without affecting the desktop view? [closed]
- WooCommerce: How to insert filtered attribute(s) in page title of archive?
- Multiple Pricing [closed]
- WOOF product filter prevent from loading on wordpress search result page
- Adding product on sale into specific category after creation
- How to select the first product variant as a default?
- Remove cart functionality from WooCommerce so it doesn’t remember the products [closed]
- Apply CSS to certain product thumbnails only
- Pass values to ajax
- Send Email to Custom Field in Custom Post Type when order is Completed
- Fragments to Update Cart Counter not working on homepage – Woocommerce
- Order Woocommerce Products by On Sale and Alphabetically
- How to track product price changes?
- Woocommerce Flexslider touch functionality on desktop not working
- Filter orders in Admin area based on logged in user
- Customer Email Address
- How to echo woocomerce attributes values in dropdown box
- Add new page in WooCommerce My Account page
- Uninitialised Parameters using woocommerce_checkout_update_order_meta hook
- Woocommerce customer role doesn’t change if user is already a subscriber [closed]
- Tags pages for different Custom Post Types and WooCommerce Products sharing Post Tags
- get_posts only getting most recent product
- How to only show featured products in wooCommerce using function.php function
- How to insert link, with lightbox, that opens specific page content only
- Allow users to register on multisite through WooCommerce using the same email address
- Vendor Listing by Location
- Decrease stock quantity when a variation is sold using Woocommerce
- WooCommerce show decimals in totals [closed]
- Woocommerce Mandatory Field on Shipping Details [closed]
- Create a shortcode to show product tag name on tag archive
- How to access Woo Commerce products from within custom theme? [closed]
- error 500 in Back Office when using a woocommerce function in functions.php
- Sort by price when price is set in multiple keys