Title: php safemode on
Last modified: August 21, 2016

---

# php safemode on

 *  [derkmdt](https://wordpress.org/support/users/derkmdt/)
 * (@derkmdt)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/php-safemode-on/)
 * On my server I had PHP’s Safe mode on. So I could not use “file_get_contents”.
   Added this if-else to your code:
 *     ```
       $url = 'http://api.whatpulse.org/user.php?UserID='.$options['UserID'].'&format=json';
   
       	// Get JSON
       	if(function_exists('curl_init')) {
       		$ch = curl_init();
   
       		curl_setopt($ch, CURLOPT_URL, $url);
       		curl_setopt($ch, CURLOPT_HEADER, false);
       		curl_setopt($ch, CURLOPT_USERAGENT, 'User-Agent: WORDPRESSWIDGET/1.0');
       		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   
       		$link  = curl_exec($ch);
       		$http_code = (string)curl_getinfo($ch, CURLINFO_HTTP_CODE);
   
       		if($http_code{0} != 2)
       			return false;
   
       		curl_close($ch);
       	} else {
       		$link = file_get_contents($url);
       	}
       ```
   
 * Maybe you can update it for other users that have the same problem.
 * [http://wordpress.org/plugins/whatpulse-widget-for-wordpress/](http://wordpress.org/plugins/whatpulse-widget-for-wordpress/)

The topic ‘php safemode on’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/whatpulse-widget-for-wordpress_a9d1e4.
   svg)
 * [Whatpulse Widget](https://wordpress.org/plugins/whatpulse-widget-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/whatpulse-widget-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/whatpulse-widget-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/whatpulse-widget-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/whatpulse-widget-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/whatpulse-widget-for-wordpress/reviews/)

## Tags

 * [file_get_contents](https://wordpress.org/support/topic-tag/file_get_contents/)

 * 0 replies
 * 1 participant
 * Last reply from: [derkmdt](https://wordpress.org/support/users/derkmdt/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/php-safemode-on/)
 * Status: not resolved