Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/force ssl admin

This page redirects to an external site: https://developer.wordpress.org/reference/functions/force_ssl_admin/

Description

Determine whether the administration panel should be viewed over SSL. This function relies on the FORCE_SSL_ADMIN constant that is set in the wp-config.php file if you're using your site over SSL.

The force parameter will change the return value of this function until it is reset.

Usage

<code style="color: #000000"> <span style="color: #0000BB"><?php force_ssl_admin</span><span style="color: #007700">(); </span><span style="color: #0000BB">?></span> </code>

Default Usage

<code style="color: #000000"> <span style="color: #0000BB"><?php </span><span style="color: #007700">if ( </span><span style="color: #0000BB">force_ssl_admin</span><span style="color: #007700">() ) { echo </span><span style="color: #DD0000">'Administration should be performed over SSL'</span><span style="color: #007700">; } </span><span style="color: #0000BB">?></span> </code>

Changing the Return Value

<code style="color: #000000"> <span style="color: #0000BB"><?php
force_ssl_admin</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);
if ( </span><span style="color: #0000BB">force_ssl_admin</span><span style="color: #007700">() ) {
  echo </span><span style="color: #DD0000">'Administration should be performed over SSL'</span><span style="color: #007700">;
} else {
  echo </span><span style="color: #DD0000">'This code will never execute'</span><span style="color: #007700">;
}
</span><span style="color: #0000BB">force_ssl_admin</span><span style="color: #007700">(</span><span style="color: #0000BB">false</span><span style="color: #007700">);
if ( </span><span style="color: #0000BB">force_ssl_admin</span><span style="color: #007700">() ) {
  echo </span><span style="color: #DD0000">'This code will never execute'</span><span style="color: #007700">;
} else {
  echo </span><span style="color: #DD0000">'Administration should NOT be performed over SSL'</span><span style="color: #007700">;
}
</span><span style="color: #0000BB">?></span> </code>

Resetting the Return Value

<code style="color: #000000"> <span style="color: #0000BB"><?php force_ssl_admin</span><span style="color: #007700">(</span><span style="color: #0000BB">FORCE_SSL_ADMIN</span><span style="color: #007700">); </span><span style="color: #0000BB">?></span> </code>

Parameters

$force
(boolean) (optional) If provided, the return value will be reset to this value on the next call.
Default: None

Returns

(boolean) 
True if administration should be performed over SSL, false otherwise

Changelog

Since: 2.6.0

Source Code

force_ssl_admin() is located in wp-includes/functions.php.

Related

force_ssl_login()

force_ssl_content()

Administration_Over_SSL

See also index of Function Reference and index of Template Tags.