Back to Top

How to allow External domain in WordPress?

Allow External domain in Wordpress

Hello All, Happy New Year 🙂 .In this quick article I will show, how to allow external url/host in wordpress.Recently i was working with wordpress for getting data from external feed url.

So, When I tried to access data from same domain,it was working fine but when i tried to access data from other domain/host, I got following error:

WP HTTP Error: A valid URL was not provided

I googled to get solution for above error in wordpress and what does it mean. This error occur because by default external urls are disabled in wordpress for security reason.So you need to allow external host/domain explicitly using following line of code into your functions.php file or your plugin’s main file:

add_filter( 'http_request_host_is_external', 'allow_external_host', 10, 3 );
function allow_external_host( $allow, $host, $url ) {
	if ( $host == 'your-domain.com' ) 
		$allow = true; 
	return $allow; 
}

Here,I have used http_request_host_is_external filter which is used to check HTTP request is external or not.In condiiton pass your external domain you want to allow.

So that’s it for now from my side. Hope this article will be useful to someone.

Suggested Reading:

Post via e-mail in WordPress
Customize Contact Form 7 in WordPress
User Roles in WordPress

If you have any query or question,tell us in the comment section :). Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How To Store Binary Data in PHP

Posted on 7 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 5 years ago

Bhumi

Hello world

Updated 1 month ago

Nick Carter

In depth Understanding of Laravel Core

Updated 3 months ago

Bhumi

ECMAScript 6 New Features – 2

Updated 1 year ago

Bhumi

The Reader’s Poll – August 2014

Posted on 5 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi