Skip to:
Content
Pages
Categories
Search
Top
Bottom

Logout button redirect to home page

  • Hi, I have placed a button in the menu for users to logout, but it directs them to the WordPress login page, I would like the button to redirect them to homepage instead. I have currently set the button´s css class to “function-is-user-logged-in” so only logged in users can see it. I would like to know if I can achieve the redirect with a css class too.

    I have also installed the “BpDev Logout Redirect to Mainsite for Mu/BP” plugin, but that is having no effect over the logout button (it does work with the Buddybar´s logout button though…).

    I would appreciate any tips. Please, as usual, bear in mind that i have very limited coding skills. Thanks in advance for all the kind help and replies.

    Best,

    Erik.

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

  • modemlooper
    Moderator

    @modemlooper

    `<a href="” title=”Logout”>Logout`

    Hi and thanks for your reply. Would you mind explaining where exactly I need to insert that code, and also, if, for instance, my home page is: http://www.canarias2nite.com , where in the code provided would I insert the url?

    Excuse my complete lack of coding skills, I just wish I knew better..

    Best,

    Erik.


    modemlooper
    Moderator

    @modemlooper

    Anywhere you want a logout link you can place the code. Header.php will show on everypage

    home_url() is the site you’re on main page. If you want another URL use code below and put in URL you want

    `<a href="” title=”Logout”>Logout`

    Hi again, and sorry for the hassle. I am using Mingle Theme for Buddypress. Mingle allows for two menus (right and left). I have currently set the logout button to the right menu (and to be visible only when users are logged in). I guess what I´m wondering is if there is a way of actually setting the redirection function from within the menu (in the button, in the classes or in the link code).

    Thanks again for your time.

    Erik.


    modemlooper
    Moderator

    @modemlooper

    You can also filter logout link. Place this in bp-custom.php or your themes functions.php

    `add_filter(‘logout_url’, ‘my_filtered_logout’);
    my_filtered_logout($logout_url, $redirect) { return “URL-after-logout”; }`


    freddy mcbob
    Participant

    @yeshourun

    @modemlooper for this code:
    `add_filter(‘logout_url’, ‘my_filtered_logout’);
    my_filtered_logout($logout_url, $redirect) { return “URL-after-logout”; }` where do I put the URL where I want members to get redirected to?


    modemlooper
    Moderator

    @modemlooper

    replace text URL-after-logout with a url


    freddy mcbob
    Participant

    @yeshourun

    @modemlooper that didnt work… It said I had an error.


    modemlooper
    Moderator

    @modemlooper

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Logout button redirect to home page’ is closed to new replies.
Skip to toolbar