• Hi there,

    background: latest version of root install w/p + Buddy press + s2member pro.
    aim: redirect members to home page on log out, rather than back to the default of the membership options page – just like the options in the s2m login widgit!

    i’ve searched the forums and come up with some code, but not the exact location of where to put it… so what i have is this:

    <a href="<?php echo S2MEMBER_LOGOUT_PAGE_URL; ?>&redirect_to=%2Fgoodbyepage%2F">Logout</a>

    or this…

    <a href="<?php echo wp_logout_url('http://yoursite.com/goodbyepage'); ?>" title="Logout">Logout</a>

    from the old forum here http://www.s2member.com/forums/topic/logout-redirect/

    So where exactly would i put this? In my child theme functions.php? and if so, just as it is? or can i add it to a menu link, so in the alt title for the buddypress log out menu link?

    Many thanks – any help much appreciated!

    https://wordpress.org/plugins/s2member/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Most logical place for me would be the theme’s templates, where you have “logout” link. In this case may need to lock the toolbar, or to remove the link there, as it is out of the theme.

    Thread Starter 5high

    (@5high)

    Thanks Krumch. Sorry, I’ve just realised I posted the wrong link – I’d looked at so many! This is the one I was referring to: http://www.s2member.com/forums/topic/redirect-on-logout/.

    I think templates are a step too far for me – or is this something I would ask the theme author about?

    re. locking the toolbar, I’ve disabled it for all users other than admins already so that shouldn’t be an issue.

    Or perhaps Raam – @Raaam or Roger – @scene13 could confirm where the code should/could be placed?

    Cheers.

    Where actually you need it? Place it there. If not familiar with PHP and templates, ask someone who can.

    Thread Starter 5high

    (@5high)

    Well it seems to be working now – but with a totally different fix.

    After heaps more reading I put this code (below) into my child theme functions.php file:

    /* add in redirect for all logout to PH home page */ add_action('wp_logout',create_function('','wp_redirect(home_url());exit();'));

    Hope this helps others who are looking for the same solution – as it’s a very commonly asked question on the Wp and s2m forums!

    And if anyone sees an obvious mistake in the above, please let me know!

    Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘add log out redirect in child theme functions.php?’ is closed to new replies.