Title: Setting SimplePie user agent
Last modified: August 20, 2016

---

# Setting SimplePie user agent

 *  [Erik](https://wordpress.org/support/users/erikalm/)
 * (@erikalm)
 * [13 years ago](https://wordpress.org/support/topic/setting-simplepie-user-agent/)
 * I am trying to set the user agent string for SimplePie.
 * I have tried to change the constant in the `wp-o-matic/inc/simplepie/simplepie.
   class.php` file by replacing the original define of SIMPLEPIE_USERAGENT.
 * However, when I check the HTTP-request from WP-o-Matic it still uses the “old”
   user agent string.
 * I’ve also tried to set this value using phprc, with the same result.
 * What is the recommended way for setting the user agent string when using SimplePie
   with WP-o-Matic?
 * I looked in the code for SimplePie and noticed the constructor of the SimplePie
   class accepts a user agent parameter, and that neither SIMPLEPIE_USERAGENT nor
   user agent from phprc is used if that value is set.
 * Do you set the user agent in the creation of the SimplePie class?
 * Kind Regards,
 * /Erik
 * [http://wordpress.org/extend/plugins/wp-o-matic/](http://wordpress.org/extend/plugins/wp-o-matic/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Erik](https://wordpress.org/support/users/erikalm/)
 * (@erikalm)
 * [13 years ago](https://wordpress.org/support/topic/setting-simplepie-user-agent/#post-3608369)
 * > I looked in the code for SimplePie and noticed the constructor of the SimplePie
   > class
 * Sorry about this, it wasn’t the SimplePie class but the SimplePie_File class…
 *  Thread Starter [Erik](https://wordpress.org/support/users/erikalm/)
 * (@erikalm)
 * [13 years ago](https://wordpress.org/support/topic/setting-simplepie-user-agent/#post-3608395)
 * The problems I’ve had did not depend on how to set the user agent (at least not
   only).
 * However this can be done (for `SimplePie`) setting the user_agent variable in
   php.ini, phprc or .htaccess.
 * The problem with WP-o-Matic’s implementation (or if it’s SimplePie’s) is that
   you seem to have to create the SimplePie-class with the URL as an argument in
   order for the system to pick up the changed user_agent string setting.
 * As things stand now, you cannot change the user_agent setting and make WP-o-Matic
   use it.
 * I solved this by adding a manual user agent string in the part of `wp-o-matic/
   wpomatic.php` that creates the `SimplePie` class.
 * I did this by adding the following statement after the `$feed` variable had been
   created. I also allowed for the URL to be set to be on the safe side (meaning
   I added the line after the `$feed->set_feed_url($url);`).
 * This is the line I added:
 * `$feed->set_useragent('Mozilla/6.0 (Windows NT 6.2; WOW64; rv:16.0.1) Gecko/20121011
   Firefox/16.0.1');`
 * Some RSS freeds will still fail (due to a bug that makes WP-o-Matic handle ampersands`&`
   incorrectly)… – see my post about that…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Setting SimplePie user agent’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-o-matic_ffffff.svg)
 * [WP-o-Matic](https://wordpress.org/plugins/wp-o-matic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-o-matic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-o-matic/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-o-matic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-o-matic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-o-matic/reviews/)

## Tags

 * [simplepie](https://wordpress.org/support/topic-tag/simplepie/)
 * [UserAgent](https://wordpress.org/support/topic-tag/useragent/)

 * 2 replies
 * 1 participant
 * Last reply from: [Erik](https://wordpress.org/support/users/erikalm/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/setting-simplepie-user-agent/#post-3608395)
 * Status: not a support question