- This topic has 2 replies, 2 voices, and was last updated 9 years, 3 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
WordPress Membership Plugin
Simple Membership Plugin › Forums › Simple Membership Plugin › Custom redirect after login
Tagged: swpm_after_login
I am trying to redirect the user after it logs in.
I run set_redirect() at the top of my header.php
/*
* ===============================
* SET SESSION REDIRECT
* ===============================
*/
function set_redirect(){
if(isset($_GET[‘redirect’]) ){
$redirect_link = htmlspecialchars($_GET[‘redirect’]);
session_start();
$_SESSION[“redirect”] = $redirect_link;
}
}
And this is my hook in function.php
/*
* ===============================
* AFTER LOGIN REDIRECTION
* ===============================
*/
add_action(‘swpm_after_login’, ‘swpm_do_after_login_redirection’);
function swpm_do_after_login_redirection()
{
if(strpos($_SESSION[‘redirect’],’supplier’) > 0 || strpos($_SESSION[‘redirect’],’airport’) > 0 || strpos($_SESSION[‘redirect’],’operator’) > 0 || strpos($_SESSION[‘redirect’],’job’) > 0 ){
//session_start();
wp_redirect($_SESSION[‘redirect’]);
exit;
}else{
$member_profile_url = get_permalink(124);
wp_redirect($member_profile_url);
exit;
}
}
What am I doing wrong?
Hi, have you checked the following plugin yet?
Regards
There was nothing wrong with the hook I was using but the issue was with the SESSION non being passed. I resolved the problem by using $_SERVER(‘HTTP_REFERER’) instead.
Thanks