Title: Set HTTP status code 401
Last modified: July 4, 2025

---

# Set HTTP status code 401

 *  Resolved [Matthias Kittsteiner](https://wordpress.org/support/users/kittmedia/)
 * (@kittmedia)
 * [10 months, 3 weeks ago](https://wordpress.org/support/topic/set-http-status-code-401/)
 * Hi there,
 * currently, if the password protection page is displayed, it answers with an HTTP
   status code 200. However, for a protected page, this is wrong and also may result
   in problems regarding SEO. Switching to status code 401 would be better.
 * If you implement this, it would also be great to make it filterable (since I 
   use some logic to bypass the password protection and then would also need to 
   change the status code).
 * Currently, my implementation for the status code looks like this:
 *     ```wp-block-code
       /** * Set an HTTP status code of 401, if password protection is enabled. */function set_status_code(): void {	if ( ! \class_exists( 'Password_Protected' ) ) {		return;	}		if ( my_condition ) {		return;	}		$password_protected = new \Password_Protected();		if ( $password_protected->is_active() ) {		\status_header( 401 );	}}\add_action( 'wp', 'set_status_code' );
       ```
   
 * Best regards,
   Matthias

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

 *  Plugin Support [Muhammad Usama Azad](https://wordpress.org/support/users/usamaazad99/)
 * (@usamaazad99)
 * [10 months, 3 weeks ago](https://wordpress.org/support/topic/set-http-status-code-401/#post-18540924)
 * Hi [@kittmedia](https://wordpress.org/support/users/kittmedia/) ,
 * I hope you are doing well,
 * Thank you for reaching out to the WP Experts Support Team. I’m glad to assist
   you today.
 * I’ll discuss your query with our Technical Team and get back to you shortly.
 * We appreciate your patience.
 * Thanks & Regards,
   WP Experts Support Team
 *  Plugin Support [Muhammad Usama Azad](https://wordpress.org/support/users/usamaazad99/)
 * (@usamaazad99)
 * [10 months, 2 weeks ago](https://wordpress.org/support/topic/set-http-status-code-401/#post-18549299)
 * Hi [@kittmedia](https://wordpress.org/support/users/kittmedia/) ,
 * I hope you’re doing well!
 * Thank you so much for sharing your idea and showing how you implemented it — 
   we truly appreciate your input.
 * I just wanted to let you know that we’ve noted your suggestion, and we plan to
   include it in our upcoming release.
 * Thanks again for your valuable feedback!
 * Best regards,
   **WP Experts Support Team**

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

The topic ‘Set HTTP status code 401’ is closed to new replies.

 * ![](https://ps.w.org/password-protected/assets/icon-128x128.gif?rev=2824217)
 * [Password Protected — Lock Entire Site, Pages, Posts, Categories, and Partial Content](https://wordpress.org/plugins/password-protected/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/password-protected/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/password-protected/)
 * [Active Topics](https://wordpress.org/support/plugin/password-protected/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/password-protected/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/password-protected/reviews/)

## Tags

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

 * 2 replies
 * 2 participants
 * Last reply from: [Muhammad Usama Azad](https://wordpress.org/support/users/usamaazad99/)
 * Last activity: [10 months, 2 weeks ago](https://wordpress.org/support/topic/set-http-status-code-401/#post-18549299)
 * Status: resolved