I am looking to override a function in functions.php through a theme or plugin. Specifically, is_ssl(), which does not have any filter or action hooks. Obviously, the easy why would be to update functions.php itself, but this will leave issues with upgrade and compatibility. How could this be done.

Edit: The goal is to overwrite is_ssl() function to return true when specific flag is set in the request header.

Is it possible with the override-function?

  • I editted is_ssl() directly in wp-includes/load.php. It worked until Wordpress updated itself, so you also have to turn off auto-updates.
    – Octopus
    May 10, 2021 at 19:42

4 Answers 4


If you look at the source of the is_ssl() function you'll see it checks various $_SERVER variables. Therefore, you could try adding this to a plugin:

if ( isset( $_SERVER['HTTP_MY_CUSTOM_HEADER'] ) )
  $_SERVER['HTTPS'] = 'on';

You'd need to call that code as early as possible, ie. directly in the plugin body rather than on a hook.

  • Tested and this does work. A useful technique to force https if you're behind a reverse proxy. Sep 30, 2015 at 14:29

You cannot override a function once it is defined. That is pure PHP. Some functions are wrapped in a conditional that lets you cheat around this-- look at pluggable.php. Otherwise, you just can't do it. You'll get a fatal error.

Your best bet to solve this is probably a child theme but without a lot of details I couldn't say how to go about it, and even so success depends on how cooperative your 'parent' theme is. It may be written inis uch a way as to make this very hard on you.


There is no easy way to do this...or at least no mass-adopted way anymore. Namespace wont really work here and every update will erase a hard edit unless its in a config (messy way to do it). vQmod is an angle, but never tried it with Wordpress.

Plugins are executed before that function, so if its proxy/balancer/SSL support you need then you can spoof the $_SERVER['HTTPS'] to be 'on'. An array merge might work good here for this if you are dealing with multiple header triggers.

Keep in mind, if you are making this a plugin, prefix your folder and script(s) so they sort at the top of the file list. Example is something like -my-router.php found in -my-router folder. The dash will sort plugin to top which should render first in chain. This is needed in case other plugins call is_ssl() or something like wp_enqueue_style() before your your plugin mitigates it.

  • You can modify the plugin load order by using the activated_plugin action hook, but it's a bit of a desperate move. You're probably better to try using add_action()'s $priority argument to load your stuff first. (Also, things like vQmod don't really leverage WordPress.)
    – Pat J
    Feb 18, 2015 at 19:19
  • @PatJ Aye but what happens when you wanna load a plugin that has same priority? Reverts back to naming right? Also, I think its the other way around -- things like Wordpress don't really leverage vQmod :)
    – dhaupin
    Feb 18, 2015 at 20:13

After considerable research, I believe that there is no good answer to this.

The best answer would be to modify $_SERVER early on, but not every environment allows you to do this. Unfortunately, a direct hack is the only way to do this.

This is necessary behind load balancers that obfuscate ssl origin. Implementing Wordpress in Azure using Active Directory Authentication (which forces ssl, but sends all results to port 80, non-ssl), my solution was to modify is_ssl to always return true.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.