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

Search Results for 'swpm_after_login'

Simple Membership Plugin › Forums › Search › Search Results for 'swpm_after_login'

Viewing 15 results - 1 through 15 (of 19 total)
1 2 →
  • Author
    Search Results
  • September 14, 2026 at 5:18 am #32319

    In reply to: Issues after re-signing in

    BracketNights
    Participant

    Well, I found one thing and it fixed one of the problems, but I’m still having a problem with the -1 nonce/cache issue…

    The members are only logging in and out using the Simple Membership forms – no other plugin or custom code.

    I looked further and I still can’t find a caching plugin on WP nor on my host. No Redis or Memcached from what I can find (my webhost service is pretty poor at providing information though).
    I also tried this in different browsers, private mode, and with hard refreshes, all finding the same result, so I really don’t think it’s a browser issue.

    There were no wp_signon() or wp_set_auth_cookie(), but I did find an errant line of wp_set_current_user(0) which I deleted. After deletion, the login and logout seems to work correctly.

    The only remaining issue is that my custom code which requires a nonce works perfectly when not logged in, but often (not always) returns a -1 error when logged in for a short time. If I wait a while, it’ll work normally. Therefore, it has to be a nonce issue with logging in, right?
    Below are my Auth logs and my actions (in case that part is useful too).

    (Note: ‘archive’ here is not the normal archive page, it’s a custom page with php, js, and a wp-nonce)
    1118 Arrive to website, logged out, decline cookies.
    1118 Archive – working, with logged out details.
    1118 Logged in successfully.
    1118 Archive – not working, has -1 error. Console reads: “wp-admin/admin-ajax.php:1 Failed to load resource: the server responded with a status of 403 ()”.
    1119 Homepage shows logged in details correctly.
    1120 Logged out successfully, homepage shows logged out details correctly.
    1120 Archive – working, with logged out details.
    1121 Update meta whilst logged out (should not update logged in meta).
    1122 Logged in successfully.
    1122 Archive – working, with logged in details.
    1123 Logged out successfully.
    1123 Archive – working, with logged out details.
    1123 Logged in successfully.
    1123 Archive – not working, has -1 error.
    1134 Archive – working, with logged in details.

    [2026/09/12 11:18:42] – SUCCESS: Authentication request – Username: teacherpierce
    [2026/09/12 11:18:42] – SUCCESS: SwpmAuth::set_cookie() – Value of ‘remember me’ parameter:
    [2026/09/12 11:18:42] – SUCCESS: The ‘Remember me’ option is unchecked for this request, setting expiry to be a session cookie. The session cookie will expire when the browser is closed.
    [2026/09/12 11:18:42] – SUCCESS: Authentication successful for username: teacherpierce. Triggering swpm_after_login_authentication action hook.
    [2026/09/12 11:18:42] – SUCCESS: Trying wp_signon() with username: teacherpierce
    [2026/09/12 11:18:42] – SUCCESS: wp_authenticate action. Handling login for username: teacherpierce
    [2026/09/12 11:18:42] – SUCCESS: SwpmAuth::login()
    [2026/09/12 11:18:42] – SUCCESS: wp_login hook triggered. Username: teacherPierce
    [2026/09/12 11:18:42] – SUCCESS: Setting current WP user to: teacherPierce
    [2026/09/12 11:18:42] – SUCCESS: Triggering swpm_login_auth_completed_filter hook.
    [2026/09/12 11:18:42] – SUCCESS: Triggering swpm_after_login hook.
    [2026/09/12 11:18:42] – SUCCESS: After triggering the default swpm_after_login_redirect_url hook. Redirect URL: https://www.bracketnights.com/membership-login/
    [2026/09/12 11:20:24] – SUCCESS: SwpmAuth::logout() – Logout request received for username: teacherPierce
    [2026/09/12 11:20:24] – SUCCESS: SwpmAuth::logout() – Logout actions executed successfully.
    [2026/09/12 11:22:36] – SUCCESS: Authentication request – Username: teacherpierce
    [2026/09/12 11:22:36] – SUCCESS: SwpmAuth::set_cookie() – Value of ‘remember me’ parameter:
    [2026/09/12 11:22:36] – SUCCESS: The ‘Remember me’ option is unchecked for this request, setting expiry to be a session cookie. The session cookie will expire when the browser is closed.
    [2026/09/12 11:22:36] – SUCCESS: Authentication successful for username: teacherpierce. Triggering swpm_after_login_authentication action hook.
    [2026/09/12 11:22:36] – SUCCESS: Trying wp_signon() with username: teacherpierce
    [2026/09/12 11:22:36] – SUCCESS: wp_authenticate action. Handling login for username: teacherpierce
    [2026/09/12 11:22:36] – SUCCESS: SwpmAuth::login()
    [2026/09/12 11:22:36] – SUCCESS: wp_login hook triggered. Username: teacherPierce
    [2026/09/12 11:22:36] – SUCCESS: Setting current WP user to: teacherPierce
    [2026/09/12 11:22:36] – SUCCESS: Triggering swpm_login_auth_completed_filter hook.
    [2026/09/12 11:22:36] – SUCCESS: Triggering swpm_after_login hook.
    [2026/09/12 11:22:36] – SUCCESS: After triggering the default swpm_after_login_redirect_url hook. Redirect URL: https://www.bracketnights.com/membership-login/
    [2026/09/12 11:23:29] – SUCCESS: SwpmAuth::logout() – Logout request received for username: teacherPierce
    [2026/09/12 11:23:29] – SUCCESS: SwpmAuth::logout() – Logout actions executed successfully.
    [2026/09/12 11:24:09] – SUCCESS: Authentication request – Username: teacherpierce
    [2026/09/12 11:24:09] – SUCCESS: SwpmAuth::set_cookie() – Value of ‘remember me’ parameter:
    [2026/09/12 11:24:09] – SUCCESS: The ‘Remember me’ option is unchecked for this request, setting expiry to be a session cookie. The session cookie will expire when the browser is closed.
    [2026/09/12 11:24:09] – SUCCESS: Authentication successful for username: teacherpierce. Triggering swpm_after_login_authentication action hook.
    [2026/09/12 11:24:09] – SUCCESS: Trying wp_signon() with username: teacherpierce
    [2026/09/12 11:24:09] – SUCCESS: wp_authenticate action. Handling login for username: teacherpierce
    [2026/09/12 11:24:09] – SUCCESS: SwpmAuth::login()
    [2026/09/12 11:24:09] – SUCCESS: wp_login hook triggered. Username: teacherPierce
    [2026/09/12 11:24:09] – SUCCESS: Setting current WP user to: teacherPierce
    [2026/09/12 11:24:09] – SUCCESS: Triggering swpm_login_auth_completed_filter hook.
    [2026/09/12 11:24:09] – SUCCESS: Triggering swpm_after_login hook.
    [2026/09/12 11:24:09] – SUCCESS: After triggering the default swpm_after_login_redirect_url hook. Redirect URL: https://www.bracketnights.com/membership-login/

    I just noticed that it redirects me back to the homepage, not to /membership-login/. I don’t know if that’s normal or not (I prefer it with the homepage redirect anyway) but I’ll mention it as it seems different from the logs.

    Thanks again for your help. I appreciate it. I can’t figure this one out on my own, haha.

    June 6, 2025 at 6:02 am #30566
    [Resolved]

    Topic: 404 / Page Not Found after login

    in forum Simple Membership Plugin
    MacStainless
    Participant

    I’m running into an issue I cannot track down. When logging in successfully, I’m consistently brought to a page that doesn’t exist on my site – [https://timemachiner.io/?page_id=2827]

    I’ve installed the Login Redirection plugin and for each of my membership levels I’ve populated the After Login Redirection Page field with my homepage: [https://timemachiner.io]

    I’ve changed themes and that doesn’t help. I’ve turned off Lightspeed and cloudflare caching, neither of which help.

    My Login page is [https://timemachiner.io/membership-login]

    Here is what is being logged when I log in with sensitive info redacted:

    [2025/06/05 13:20:39] - SUCCESS: Authentication request using email address: myemail@example.com, Found a user record with username: MyUsername
    [2025/06/05 13:20:39] - SUCCESS: Authentication request - Username: MyUsername
    [2025/06/05 13:20:39] - SUCCESS: SwpmAuth::set_cookie() - Value of 'remember me' parameter: 
    [2025/06/05 13:20:39] - SUCCESS: The 'Remember me' option is unchecked for this request, setting expiry to be a session cookie. The session cookie will expire when the browser is closed.
    [2025/06/05 13:20:39] - SUCCESS: Authentication successful for username: MyUsername. Triggering swpm_after_login_authentication action hook.
    [2025/06/05 13:20:39] - SUCCESS: Trying wp_signon() with username: MyUsername
    [2025/06/05 13:20:39] - SUCCESS: wp_authenticate action. User with username: aaron-test is already logged in.

    I have no idea why this is happening. Hoping to get some help here.

    February 7, 2024 at 10:23 pm #27687
    [Resolved]

    Topic: Can I get some hook documentation for developing a content visibility plugin?

    in forum Simple Membership Plugin
    Anonymous
    Inactive

    I’m trying to develop a plugin to target specific IDs to show/hide visibility. In part because I don’t think the current Dynamic Menu plugin will work with the 2024 theme. I looked through the documentation but couldn’t find answers to all of my questions:

    • What hook or function can I use to retrieve the current logged-in user’s membership level?

    • Is there a hook that fires after a user’s membership level is updated?

    • Can you provide examples or best practices for using swpm_after_login and swpm_logout hooks to dynamically control content visibility?

    • How can I fetch a complete list of all membership levels, including custom ones?

    • Are there any recommendations or best practices for integrating a custom visibility control plugin, particularly for adjusting content based on membership levels?

    Thanks!

    October 11, 2022 at 6:02 pm #24597

    In reply to: Membership account auto log out every x time

    Eric iStudio101
    Participant

    I face an issue that was not there before…
    Members can’t log in any longer. Here is the log…
    Should it be the same issue than this one? Any help?
    Thanks

    [2022/10/11 19:35:02] – SUCCESS: Authentication request using email address: subscriber@wanadoo.fr, Found a user record with username: subscriber@wanadoo.fr
    [2022/10/11 19:35:02] – SUCCESS: Authentication request – Username: subscriber@wanadoo.fr
    [2022/10/11 19:35:02] – SUCCESS: Authentication successful for username: subscriber@wanadoo.fr. Executing swpm_login action hook.
    [2022/10/11 19:35:02] – SUCCESS: Trying wp_signon() with username: subscriber@wanadoo.fr
    [2022/10/11 19:35:02] – SUCCESS: wp_authenticate action. User with username: subscriber@wanadoo.fr is already logged in.
    [2022/10/11 19:35:02] – SUCCESS: wp_login hook triggered. Username: subscriber@wanadoo.fr
    [2022/10/11 19:35:02] – SUCCESS: Setting current WP user to: subscriber@wanadoo.fr
    [2022/10/11 19:35:02] – SUCCESS: Triggering swpm_after_login hook.
    [2022/10/11 19:35:02] – SUCCESS: synchronise_swpm_logout_for_wp_users() – Force wp user login sync is enabled.
    [2022/10/11 19:35:02] – SUCCESS: WP user session is logged out for this user. So logging out of the swpm session also.

    July 16, 2021 at 7:15 pm #22835

    In reply to: Hook swpm_after_login not working with Simple Membership After Login Redirection

    smythsys
    Participant

    Sorry if I am missing something but I fail to see how this is related to our issue. Login redirection is working. What is not working is the swpm_after_login hook once the plugin “Simple Membership After Login Redirection”.
    We need to execute a GTM action after a member logs in and don’t have a hook if that is not working.

    July 14, 2021 at 4:23 pm #22832
    [Support request]

    Topic: Hook swpm_after_login not working with Simple Membership After Login Redirection

    in forum Simple Membership Plugin
    smythsys
    Participant

    Hi,
    we have been asked to execute a Google Tag Manager event when someone logs into our site, or when they register, and send user data.

    I was doing tests with the login sequence, using swpm_after_login, and was getting no result.

    After some research I found https://simple-membership-plugin.com/forums/search/swpm_after_login/ where it said that the hook was not being fired when the plugin Simple Membership After Login Redirection was active. So I deactivated it and got it to work.

    But we do need that plugin as our users need to be redirected to webpages depending on their role.

    Which hook can I use for this task with the plugin enabled?

    Data: Simple Membership After Login Redirection V 1.4
    WordPress Simple Membership 4.05
    Simple Membership Custom Messages
    Simple Membership Form Builder
    Simple Membership Google recaptcha
    being used.

    Thanks in advance.

    June 6, 2020 at 11:57 am #20398
    [Support request]

    Topic: Manual Upgrade button doens\'t work

    in forum Simple Membership Plugin
    Peter
    Participant

    Hi,
    I tried all the solutions in this forum and i cant figure out why it is not working.
    After registration, Visitors have an option to upgrade their account for free with a button. I use the next shortcode:
    [swpm_update_level_to level=”3″ button_text=”Update Level”]
    After you click the button, nothing happens. It goes back to the page witch is set up to redirect to after login and also is the last page.

    I tried the debug mode but nothing shows there about the upgrade button:

    [06/06/2020 11:51 AM] – SUCCESS: Member registration complete email sent to: Peter@escapegamedesign.nl. From email address value used: Familysecrets <info@familysecrets.nl>
    [06/06/2020 11:51 AM] – SUCCESS: Auto login after registration feature is enabled in settings. Performing auto login for user: Santepeter85
    [06/06/2020 11:51 AM] – SUCCESS: Handling auto login request…
    [06/06/2020 11:51 AM] – SUCCESS: After login redirection addon. Checking if member need to be redirected.

    and login log
    [06/06/2020 11:51 AM] – SUCCESS: SwpmAuth::login()
    [06/06/2020 11:51 AM] – SUCCESS: Authentication request – Username: Santepeter85
    [06/06/2020 11:51 AM] – SUCCESS: Authentication successful for username: Santepeter85. Executing swpm_login action hook.
    [06/06/2020 11:51 AM] – SUCCESS: Trying wp_signon() with username: Santepeter85
    [06/06/2020 11:51 AM] – SUCCESS: wp_authenticate action. User with username: Santepeter85 is already logged in.
    [06/06/2020 11:51 AM] – SUCCESS: wp_login hook triggered. Username: Santepeter85
    [06/06/2020 11:51 AM] – SUCCESS: Setting current WP user to: Santepeter85
    [06/06/2020 11:51 AM] – SUCCESS: Triggering swpm_after_login hook.

    Any tips to try would be greatly appreciated!

    My last guesses: can it have anything to do with the fact that i dont use the mail to confirm the account, or that i use the login page within an iframe on the homepage?

    March 28, 2020 at 9:22 am #19965

    In reply to: swpm_after_login hook not firing

    quick_dry
    Participant

    that was how I narrowed it down to the “Simple Membership After Login Redirection” plugin having the effect.

    Activate – no swpm_after_login.

    Deactivate – swpm_after_login works _and_ lines of code immediately after the do_action call in the main swpm plugin.

    March 26, 2020 at 11:56 am #19954
    [Support request]

    Topic: swpm_after_login hook not firing

    in forum Simple Membership Plugin
    quick_dry
    Participant

    The “swpm_after_login” action does not fire when “Simple Membership After Login Redirection” plugin is activated (note: the redirection feature was not active – checkbox in its settings unchecked, but the plugin itself was activated)

    Everything runs up to the call to do_action(‘swpm_after_login’) in class.simple-wp-membership.php, but not the functions hooked onto that action, or anything in the login function afterwards.

    After deactivating the Redirection plugin it seems to run the action properly, and the following lines of code in the function.

    December 3, 2019 at 12:42 pm #19382
    [Resolved]

    Topic: Redirection after login issue on Safari v12.1.1

    in forum Simple Membership Plugin
    Shane
    Participant

    I am just about to go live with my Members Only area and was doing some browser testing, and it appears I have found an issue with the Simple Membership After Login Redirection addon.

    When testing in Chrome or Firefox, the redirection works as intended.

    However, when testing in Safari, the user is just taken to a user summary screen.
    I have 4 user groups with login redirections set up, and I have tested each one numerous times and the same issue occurs.

    Here is a copy of my login debug:
    [12/03/2019 12:30 PM] – SUCCESS: Log file reset
    ——————————————————————

    [12/03/2019 12:30 PM] – SUCCESS: Authentication request – Username: leadershipuser
    [12/03/2019 12:30 PM] – SUCCESS: Authentication successful for username: leadershipuser. Executing swpm_login action hook.
    [12/03/2019 12:30 PM] – SUCCESS: Trying wp_signon() with username: leadershipuser
    [12/03/2019 12:30 PM] – SUCCESS: wp_authenticate action. User with username: leadershipuser is already logged in.
    [12/03/2019 12:30 PM] – SUCCESS: wp_login hook triggered. Username: leadershipuser
    [12/03/2019 12:30 PM] – SUCCESS: Setting current WP user to: leadershipuser
    [12/03/2019 12:30 PM] – SUCCESS: Triggering swpm_after_login hook.
    [12/03/2019 12:30 PM] – SUCCESS: Authentication request – Username: nhsuser
    [12/03/2019 12:30 PM] – SUCCESS: Authentication successful for username: nhsuser. Executing swpm_login action hook.
    [12/03/2019 12:30 PM] – SUCCESS: Trying wp_signon() with username: nhsuser
    [12/03/2019 12:30 PM] – SUCCESS: wp_authenticate action. User with username: nhsuser is already logged in.
    [12/03/2019 12:30 PM] – SUCCESS: wp_login hook triggered. Username: nhsuser
    [12/03/2019 12:30 PM] – SUCCESS: Setting current WP user to: nhsuser
    [12/03/2019 12:30 PM] – SUCCESS: Triggering swpm_after_login hook.

    Has anyone experienced a similar issue regarding this?

    I have W3 Total Cache installed, but I have made the required changes to the page cache recommended in your documentation.

    Also if I disable the cache plugin the same issue occurs.

    Any advice would be appreciated.

    Regards,
    Shane

    October 20, 2019 at 3:42 pm #19148

    In reply to: Redirect issues (not what you think :) )

    RobL
    Participant

    After yet further debugging, I realized that there was a flaw in my belief that one environment worked while the other didn’t. The difference is that on the one environment I was logging in to /wp-admin as a WP user who is NOT an SWPM member, thus swpm_after_login hook isn’t called (for reasons I’m not yet clear on) and thus there is no problem. If on the same environment I login as a user who IS an SWPM member, the same bad issue happens.

    Unfortunately, that still leaves me unclear as to how to resolve this issue. I find it hard to believe that I’m the only SPWM consumer to have tried to login to /wp-admin/ as a user who is also an SWPM user.

    October 20, 2019 at 3:08 pm #19146

    In reply to: Redirect issues (not what you think :) )

    RobL
    Participant

    I did more debugging and it’s becoming more clear there’s something odd going on here. It would be nice if someone could comment on my situation. I turned on the SWPM debugging for an environment that has no problem and one that does and then I logged into /wp-admin. The log file content is dramatically different.

    Problem environment
    ——————-
    [10/20/2019 2:43 PM] – SUCCESS: wp_authenticate action. Empty username provided. Adding set_current_username hook to catch potential login attempt.
    [10/20/2019 2:43 PM] – SUCCESS: wp_authenticate action. Handling login for username: webmaster
    [10/20/2019 2:43 PM] – SUCCESS: SwpmAuth::login()
    [10/20/2019 2:43 PM] – SUCCESS: Authentication request – Username: webmaster
    [10/20/2019 2:43 PM] – SUCCESS: Authentication successful for username: webmaster. Executing swpm_login action hook.
    [10/20/2019 2:43 PM] – SUCCESS: Trying wp_signon() with username: webmaster
    [10/20/2019 2:43 PM] – SUCCESS: wp_authenticate action. User with username: webmaster is already logged in.
    [10/20/2019 2:43 PM] – SUCCESS: wp_login hook triggered. Username: webmaster
    [10/20/2019 2:43 PM] – SUCCESS: Setting current WP user to: webmaster
    [10/20/2019 2:43 PM] – SUCCESS: Triggering swpm_after_login hook.

    No problem environment
    ———————-
    [10/20/2019 2:45 PM] – SUCCESS: wp_authenticate action. Handling login for username: [user.name]
    [10/20/2019 2:45 PM] – SUCCESS: SwpmAuth::login()
    [10/20/2019 2:45 PM] – SUCCESS: Authentication request – Username: user.name
    [10/20/2019 2:45 PM] – SUCCESS: wp_login hook triggered. Username: user.name

    The comment in the code that throws the “Empty username provided” text to the log file, says, “empty username can mean some plugin trying to login WP user using its own methods.” So I performed a test on the problem environment. I deactivated every single plugin, except the three Simple Membership plugins (main, after login and custom messages) and when I logged in to /wp-admin the problem still happens!

    I went another step further. I hardcoded the username and password in the SWPM code to see if that would work. Unfortunately, even though the log is different the same problem exists. You’ll note that it still is saying “Executing swpm_login action hook.”

    [10/20/2019 3:17 PM] – SUCCESS: wp_authenticate action. Handling login for username: webmaster
    [10/20/2019 3:17 PM] – SUCCESS: SwpmAuth::login()
    [10/20/2019 3:17 PM] – SUCCESS: Authentication request – Username: webmaster
    [10/20/2019 3:17 PM] – SUCCESS: Authentication successful for username: webmaster. Executing swpm_login action hook.
    [10/20/2019 3:17 PM] – SUCCESS: Trying wp_signon() with username: webmaster
    [10/20/2019 3:17 PM] – SUCCESS: wp_authenticate action. User with username: webmaster is already logged in.
    [10/20/2019 3:17 PM] – SUCCESS: wp_login hook triggered. Username: webmaster
    [10/20/2019 3:17 PM] – SUCCESS: Setting current WP user to: webmaster
    [10/20/2019 3:17 PM] – SUCCESS: Triggering swpm_after_login hook.

    Please tell me what do at this point.

    Regards,
    Rob

    August 18, 2018 at 11:45 am #15224
    [Support request]

    Topic: Login after logout does not work

    in forum Simple Membership Plugin
    Jokke86
    Participant

    Hi guys,

    I’ve been coming across another issue unfortunately:
    When I login with one user, logout and then want to login with another user, I get an error.

    You can try it at my testsite here:

    http://emonkeys.be/bbb/wp-login.php
    user: *****Moderated*****
    pw: *****Moderated*****

    then when you logout and want to login with:

    user: *****Moderated*****
    pw: *****Moderated*****

    You see that the content is not shown!

    This is the log:

    [08/18/2018 11:41 AM] – SUCCESS: wp_authenticate action. Handling login for username: partner
    [08/18/2018 11:41 AM] – SUCCESS: SwpmAuth::login()
    [08/18/2018 11:41 AM] – SUCCESS: Authentication request – Username: partner
    [08/18/2018 11:41 AM] – SUCCESS: Authentication successful for username: partner. Executing swpm_login action hook.
    [08/18/2018 11:41 AM] – SUCCESS: Trying wp_signon() with username: partner
    [08/18/2018 11:41 AM] – SUCCESS: wp_authenticate action. User with username: partneris already logged in.
    [08/18/2018 11:41 AM] – SUCCESS: Setting current WP user to: partner
    [08/18/2018 11:41 AM] – SUCCESS: Triggering swpm_after_login hook.
    [08/18/2018 11:41 AM] – SUCCESS: wp_authenticate action. Handling login for username: investor
    [08/18/2018 11:41 AM] – SUCCESS: SwpmAuth::login()

    Thanks!
    Jonas

    August 16, 2018 at 11:51 am #15217

    In reply to: Simultaneously logins for one "user"

    Jokke86
    Participant

    Hi,

    I did what you asked, this is the log:

    [08/16/2018 11:49 AM] – SUCCESS: SwpmAuth::login()
    [08/16/2018 11:49 AM] – SUCCESS: Authentication request – Username: partner
    [08/16/2018 11:49 AM] – SUCCESS: Authentication successful for username: partner. Executing swpm_login action hook.
    [08/16/2018 11:49 AM] – SUCCESS: Trying wp_signon() with username: partner
    [08/16/2018 11:49 AM] – SUCCESS: wp_authenticate action. User with username: partneris already logged in.
    [08/16/2018 11:49 AM] – SUCCESS: Setting current WP user to: partner
    [08/16/2018 11:49 AM] – SUCCESS: Triggering swpm_after_login hook.

    But somehow I was able now to view the partner info on both computers (something which wasn’t last week), very strange, but so good so far!!

    February 15, 2018 at 8:58 am #13370
    [Support request]

    Topic: Link directly to membership URL via login (swpm_after_login_redirect_url)

    in forum Simple Membership Plugin
    r_ag
    Participant

    Hi,

    I have a solution where all users are redirected to login if they are not already logged in.

    However the customer wants to be able to send links to specific pages to the site users by mail. The problem is that if the users are not logged in, they are redirected to login and the link URL is lost.

    To fix this my idea is to save the original URL before redirecting to login and then use swpm_after_login_redirect_url to redirect to the original URL after login. However I cannot get it to work. My current code is like this:

    
    $originalURL
    
    add_filter( 'pre_get_posts', 'swpm_auto_redirect_non_members' );
    function swpm_auto_redirect_non_members($originalURL) {
        if (!current_user_can( 'manage_options' )) {
    
            // save original URL
            $originalURL = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    
            // if not logged in, redirect to login
            if(!SwpmMemberUtils::is_member_logged_in() && !(is_page('membership-login' ) || is_page('password-reset') )){
                //echo '<!-- page is test -->';
                wp_redirect( get_home_url().'/membership-login/' );
            }
    
            if(is_page('membership-login')){
                echo '<!-- page is membership-login -->';
            }
        }
    }
    
    add_filter('swpm_after_login_redirect_url', 'redirectToURL');
    function redirectToURL($originalURL) {
    
        return $originalURL;
    }
    

    What am I doing wrong? If I replace return $originalURL with a static URL like ‘https://www.google.com&#8217; it works, so I guess my error lies in assigning a correct URL to $originalURL. I have also tried using global $originalURL inside the functions instead of passing it as a parameter.

  • Author
    Search Results
Viewing 15 results - 1 through 15 (of 19 total)
1 2 →
Next Page »

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