Creating a logout link in a standard custom menu

March 2014 WordPress Theme
GK User
Wed Jun 17, 2015 3:21 pm
Hi there, I am trying to create a new link in a custom menu for a logout menu item. I know how to create a custom menu link for example. But what should the link be exactly in order for the user to logout of WordPress. My test site is http://www.jamjosandbox.com/mag and just to be clear I do not need anything referenced here for example: https://wordpress.org/support/topic/log ... front-page whereby the user sees a logout button if logging in and a login when logged out. I just want to create a custom menu link and then link to the logout url but I am struggling to see what this is? Any help would be much appreciated as I will not be using the logout provided by News2 theme.

Thanks
User avatar
Expert Boarder

GK User
Wed Jun 17, 2015 10:02 pm
User avatar
Moderator

GK User
Wed Jun 17, 2015 11:55 pm
Thanks for the follow up here. Ok so I tried the first 2 methods you posted and the issue is that shortcodes are stripped out menu you try and create a menu item under Appearance > Menus and then you enter the shortcode in the menu url area. You get what you see attached here - basically the shortcode brackets are stripped out.

The plugin again adds a shortcode which again you cannot add to the Appearance menu item when you are creating a menu item. For some reason it seems very diificult in wordpress to create a menu in the appearance area that logs a user out. If you have any ideas on how to stop the shortcode from being stripped back to a link like the screenshot here then great as that might work. Thanks
User avatar
Expert Boarder

GK User
Thu Jun 18, 2015 8:25 am
Did you try this solution?
https://wordpress.org/support/topic/log ... in-30-menu

or a plugin from my 3rd url?
User avatar
Moderator

GK User
Thu Jun 18, 2015 9:33 am
@piotr, In that thread I tried the solution https://wordpress.org/support/topic/log ... in-30-menu at the bottom of the tread, it does not logout the user unfortunately.

The plugin you mention here: https://wordpress.org/plugins/logout-button/ relies on shortcodes and I cannot put shortcodes in a menu item under the Appearance menu as it stripped down the shortcode brackets and it does not work also.

The plugins listed here: https://wordpress.org/support/topic/log ... in-30-menu are all 2 years old but again they offer logout in a widget or a shortcode.

I thought this would be easy enough but its proving very difficult. Basically all I want is to be able to go into Appearance > Menus and create a custom link menu item called logout with a link that looks something like this:

http://www.mykidstime.com/?action=logou ... ething.com

which would log the user out but that is not doing it unfortunately.
User avatar
Expert Boarder

GK User
Thu Jun 18, 2015 11:35 am
Please contact with the plugin author, because the issue is not connected with our theme directly.

This solution also should work:
http://coffeecupweb.com/how-to-add-a-lo ... ress-menu/
User avatar
Moderator

GK User
Thu Jun 18, 2015 12:02 pm
Thanks Piotr, I tried that also, all that does is force a menu item into the primary or top menu for that matter. I want to be able to add the menu item in the Appearance > Menu and control where it shows in a dropdown so again not ideal. I guess I asked here first because I thought you could provide the straight forward url that you use on your theme when you login and then there is a link on the page here you logout. I just could not figure out what the url should be but obviously there is alot more to this than just a url that logs people out. Thanks for your time I will try and ask in the wordpress forums and see if there is a solution. Thanks
User avatar
Expert Boarder

GK User
Thu Jun 18, 2015 10:24 pm
In the News2 theme files we are using simple wp_logout_url function:
Code: Select all
<a href="<?php echo wp_logout_url(); ?>" id="gk-login"><?php _e('Logout', GKTPLNAME) ?></a>

but unfortunately you can't use PHP function in your menu item url.
User avatar
Moderator

GK User
Fri Jun 19, 2015 6:43 am
Thanks Piotr, basically that is my problem, I cant use php and I cant use shortcodes in a menu item so it sounds like you cannot actually control a logout link placement in the Appearance > menu area which is a real shame here. I will try other ways and see what I can come up with. Thanks for your time.
User avatar
Expert Boarder


cron