Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

Custom redirect after login

Simple Membership Plugin › Forums › Simple Membership Plugin › Custom redirect after login

Tagged: swpm_after_login

  • This topic has 2 replies, 2 voices, and was last updated 9 years, 3 months ago by carcangium.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 20, 2017 at 3:16 pm #10215
    carcangium
    Participant

    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?

    February 20, 2017 at 9:57 pm #10222
    mbrsolution
    Moderator

    Hi, have you checked the following plugin yet?

    Regards

    February 21, 2017 at 1:02 pm #10231
    carcangium
    Participant

    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

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy