{"id":124651,"date":"2023-07-02T18:15:44","date_gmt":"2023-07-02T17:15:44","guid":{"rendered":"https:\/\/wpsimplefix.com\/?p=124651"},"modified":"2026-09-24T17:40:46","modified_gmt":"2026-09-24T17:40:46","slug":"logout-link-without-wp-nonce-confirmation","status":"publish","type":"post","link":"https:\/\/chkserv.com\/blog\/logout-link-without-wp-nonce-confirmation\/","title":{"rendered":"Create A LOGOUT link without WP-nonce confirmation"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">By default, WordPress provides a standard logout link, which includes WP-nonce logout confirmation for added security. However, there are scenarios where website owners may wish to customize the process for a smoother user experience.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s happening?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>When you create a logout link to;<br><strong><code>https:\/\/domain.com\/wp-login.php?action=logout<\/code><\/strong><\/li>\n\n\n\n<li>But when your site members or users click the logout link or button, it asks for a confirmation that they wish to logout of the website. A bit Annoying, right?<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What can we do?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s simple.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Login to your <a href=\"https:\/\/filezilla-project.org\/download.php?type=client\" target=\"_blank\" rel=\"nofollow noopener\">FTP client<\/a> or File manager in cPanel.<\/li>\n\n\n\n<li>Paste this snippet into your active theme&#8217;s\u00a0functions.php and make sure to replace <strong>domain.com <\/strong>with your own domain on line 8.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-preformatted has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-1\"><code readonly=\"true\">add_action('check_admin_referer', 'logout_without_confirm', 10, 2);<br>function logout_without_confirm($action, $result)<br>{<br>    \/**<br>     * Allow logout without confirmation<br>     *\/<br>    if ($action == \"log-out\" &amp;&amp; !isset($_GET['_wpnonce'])) {<br>        $redirect_to = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : 'https:\/\/domain.com';<br>        $location = str_replace('&amp;amp;', '&amp;', wp_logout_url($redirect_to));<br>        header(\"Location: $location\");<br>        die;<br>    }<br>}<span style=\"white-space: pre-wrap; font-family: serif;\">\t<\/span><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You may now construct your own user logout link and place it wherever you like! Example, in your menu, or anywhere in your page content as a hyperlink or a button.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, WordPress provides a standard logout link, which includes WP-nonce logout confirmation for added security. However, there are scenarios where website owners may wish to customize the process for a smoother user experience. What&#8217;s happening? What can we do? It&#8217;s simple. add_action(&#8216;check_admin_referer&#8217;, &#8216;logout_without_confirm&#8217;, 10, 2);function logout_without_confirm($action, $result){ \/** * Allow logout without confirmation *\/ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":123530,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[195,196,6,7,197],"class_list":["post-124651","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security","tag-confirmation","tag-logout","tag-security","tag-wordpress","tag-wp-nonce"],"_links":{"self":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts\/124651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/comments?post=124651"}],"version-history":[{"count":2,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts\/124651\/revisions"}],"predecessor-version":[{"id":136639,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/posts\/124651\/revisions\/136639"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/media\/123530"}],"wp:attachment":[{"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/media?parent=124651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/categories?post=124651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chkserv.com\/blog\/wp-json\/wp\/v2\/tags?post=124651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}