Title: force_ssl_admin
Published: April 25, 2014
Last modified: August 20, 2026

---

# force_ssl_admin( string|bool|null $force = null ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#wp--skip-link--target)

Determines whether to force SSL used for the Administration Screens.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#parameters)󠁿

 `$force`string|bool|nulloptional

Whether to force SSL in admin screens.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#return)󠁿

 bool True if forced, false if not forced.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#more-information)󠁿

Determine whether the administration panel should be viewed over SSL. This function
relies on the [ FORCE_SSL_ADMIN](https://wordpress.org/support/article/administration-over-ssl/)
constant that is set in the [ wp-config.php file](https://wordpress.org/support/article/editing-wp-config-php/)
if you’re using your site [ over SSL](https://wordpress.org/support/article/administration-over-ssl/).

The [ force](https://codex.wordpress.org/Function_Reference/force_ssl_admin#Parameters)
parameter will change the [ return value](https://codex.wordpress.org/Function_Reference/force_ssl_admin#Returns)
of this function until it is reset.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#source)󠁿

    ```php
    function force_ssl_admin( $force = null ) {
    	static $forced = false;

    	if ( ! is_null( $force ) ) {
    		$old_forced = $forced;
    		$forced     = (bool) $force;
    		return $old_forced;
    	}

    	return $forced;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/functions.php#L6418)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/functions.php#L6418-L6428)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#related)󠁿

| Used by | Description | 
| [get_rest_url()](https://developer.wordpress.org/reference/functions/get_rest_url/)`wp-includes/rest-api.php` |

Retrieves the URL to a REST endpoint on a site.

  | 
| [auth_redirect()](https://developer.wordpress.org/reference/functions/auth_redirect/)`wp-includes/pluggable.php` |

Checks if a user is logged in, if not it redirects them to the login page.

  | 
| [force_ssl_login()](https://developer.wordpress.org/reference/functions/force_ssl_login/)`wp-includes/deprecated.php` |

Whether SSL login should be forced.

  | 
| [wp_ssl_constants()](https://developer.wordpress.org/reference/functions/wp_ssl_constants/)`wp-includes/default-constants.php` |

Defines SSL-related WordPress constants.

  | 
| [set_url_scheme()](https://developer.wordpress.org/reference/functions/set_url_scheme/)`wp-includes/link-template.php` |

Sets the scheme for a URL.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.6.0](https://developer.wordpress.org/reference/since/2.6.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#comment-content-1037)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/force_ssl_admin/#comment-1037)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%23comment-1037)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%23comment-1037)
 4.  **Default Usage**
 5.      ```php
         <?php if ( force_ssl_admin() ) { echo 'Administration should be performed over SSL'; } ?> 
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%3Freplytocom%3D1037%23feedback-editor-1037)
 7.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#comment-content-1038)
 8.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/force_ssl_admin/#comment-1038)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%23comment-1038)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%23comment-1038)
 10. **Changing the Return Value**
 11.     ```php
         <?php
         force_ssl_admin(true);
         if ( force_ssl_admin() ) {
           echo 'Administration should be performed over SSL';
         } else {
           echo 'This code will never execute';
         }
         force_ssl_admin(false);
         if ( force_ssl_admin() ) {
           echo 'This code will never execute';
         } else {
           echo 'Administration should NOT be performed over SSL';
         }
         ?> 
         ```
     
 12.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%3Freplytocom%3D1038%23feedback-editor-1038)
 13.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/force_ssl_admin/?output_format=md#comment-content-1039)
 14.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/force_ssl_admin/#comment-1039)
 15. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%23comment-1039)
     Vote results for this note: -1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%23comment-1039)
 16. **Resetting the Return Value**
 17.     ```php
         <?php force_ssl_admin(FORCE_SSL_ADMIN); ?>
         ```
     
 18.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F%3Freplytocom%3D1039%23feedback-editor-1039)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fforce_ssl_admin%2F)
before being able to contribute a note or feedback.