redirecting

Hello Everyone,

I have got a login page and i would like to log out and redirect the page back to the homepage the code works but i can only seem to log out on the screen they are currently on. Here is my code:

[php]$link_string_logout = ‘<a href="’. wp_logout_url($_SERVER[‘REQUEST_URI’]) .’" title="’.__('Log

out’,‘logout’).’">’.__(‘Log out’,‘logout’).’’;[/php]

Any help would be greatly appreciated

Thank You

REQUEST_URI = entire request path (/foo/f.php?query=string)
so i’m assuming wp_logout_url($_SERVER[‘REQUEST_URI’]) is grabbing the page that they are currently on when they logout… so it would redirect to that page…

Try using this instead. It redirects to the home page, rather than the URI.

[PHP]wp_logout_url(home_url());[/PHP]

Two Ways you can do it:

logout.php

[php]<?php
session_start();
session_destroy();
header(“location:index.php”);
?>[/php]
After user clicks logout in your page, this will tell take you to the index page, or whatever page you specify.

  1. And a more gracious way would be:

[php]echo ‘You have been succesfully logged out’;

session_start();
session_destroy();

';[/php] Here you specify the delay time before going to the re-directed page, and you can actually echo a message before redirecting.

or that… but since you use wordpress, might as well use wordpress’es default home redirect :stuck_out_tongue:

they all worked thank you :smiley: very much

glad it worked :D… yw :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service