Title: Plugin doesn&#8217;t work after $wp_query-&gt;set_404()
Last modified: August 25, 2023

---

# Plugin doesn’t work after $wp_query->set_404()

 *  Resolved [container](https://wordpress.org/support/users/container/)
 * (@container)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/plugin-doesnt-work-after-wp_query-set_404/)
 *     ```wp-block-code
       global $wp_query;
       $wp_query->set_404();
       echo wp_login_url();
       ```
   
 * The meaning of the above code is that it jumps the site to a 404 page and outputs
   the login page of the site as a string afterward.
 * However, after enabling WPS Hide Login plugin and using the above code in the
   website, wp_login_url() will return the string “#” instead of the correct login
   address. After disabling the WPS Hide Login plugin wp_login_url() returns the
   normal login address.
 * I think this is caused by a bug in the WPS Hide Login plugin and you can reproduce
   the issue in your project using the three lines of code above.
    -  This topic was modified 2 years, 9 months ago by [container](https://wordpress.org/support/users/container/).

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

 *  Thread Starter [container](https://wordpress.org/support/users/container/)
 * (@container)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/plugin-doesnt-work-after-wp_query-set_404/#post-17002384)
 *     ```wp-block-code
       public function login_url($login_url, $redirect, $force_reauth) {
           if (is_404()) {
               return '#';
           }
   
           if ($force_reauth === false) {
               return $login_url;
           }
   
           if (empty($redirect)) {
               return $login_url;
           }
   
           $redirect = explode('?', $redirect);
   
           if ($redirect[0] === admin_url('options.php')) {
               $login_url = admin_url();
           }
   
           return $login_url;
       }
       ```
   
 * Oops! I found the above code in the plugin, it seems the plugin is intentionally
   setting the 404 status to return `'#'`, but I guess not everyone expects this,
   sometimes I would like to provide a button on the error page for the user to 
   log in or something like that, so would it be possible to provide a switch on
   the Settings page for this function?
 * Switch on would output `'#'`, otherwise the correct link.
 *  Plugin Support [MaximeWPS](https://wordpress.org/support/users/seinomedia/)
 * (@seinomedia)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/plugin-doesnt-work-after-wp_query-set_404/#post-17027362)
 * Hello,
 * Thanks for using WPS Hide Login.
 * You can set a personalized slug for 404 in WPS Hide Login settings below the 
   secret slug field.

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

The topic ‘Plugin doesn’t work after $wp_query->set_404()’ is closed to new replies.

 * ![](https://ps.w.org/wps-hide-login/assets/icon-256x256.png?rev=1820667)
 * [WPS Hide Login](https://wordpress.org/plugins/wps-hide-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wps-hide-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wps-hide-login/)
 * [Active Topics](https://wordpress.org/support/plugin/wps-hide-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wps-hide-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wps-hide-login/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [MaximeWPS](https://wordpress.org/support/users/seinomedia/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/plugin-doesnt-work-after-wp_query-set_404/#post-17027362)
 * Status: resolved