Plugin Directory

Changeset 3374724


Ignore:
Timestamp:
10/08/2025 12:13:05 AM (6 months ago)
Author:
wp.insider
Message:

Support added for the Social Login Addon

Location:
simple-membership-after-login-redirection/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simple-membership-after-login-redirection/trunk/readme.txt

    r3271703 r3374724  
    55Requires at least: 4.5
    66Tested up to: 6.8
    7 Stable tag: 1.9
     7Stable tag: 2.0
    88License: GPLv2 or later
    99
     
    3232
    3333== Changelog ==
     34
     35= 2.0 =
     36* Support added for the [Social Login Addon](https://simple-membership-plugin.com/simple-membership-social-login-addon/) - now the after login redirection will also work when the member logs in using social login.
    3437
    3538= 1.9 =
  • simple-membership-after-login-redirection/trunk/swpm-after-login-redirection.php

    r3229099 r3374724  
    22/*
    33Plugin Name: Simple Membership After Login Redirection
    4 Version: 1.9
     4Version: 2.0
    55Plugin URI: https://simple-membership-plugin.com/
    66Author: smp7, wp.insider
     
    1313}
    1414
    15 define( 'SWPM_ALR_VERSION', '1.9' );
     15define( 'SWPM_ALR_VERSION', '2.0' );
    1616define( 'SWPM_ALR_CONTEXT', 'swpm_alr');
    1717
     
    2121add_filter('swpm_after_login_url', 'swpm_alr_after_login_url');
    2222add_filter('swpm_get_login_link_url', 'swpm_alr_append_query_arg_if_applicable');
     23add_filter('swpm_sl_after_login_redirect_url', 'swpm_alr_do_after_social_login_redirection', 10, 2);
    2324
    2425// The following 6 filters are used to allow the usage of the swpm_redirect_to parameter, if it is currently present in the page's URL
     
    129130}
    130131
     132function swpm_alr_do_after_social_login_redirection($redirect_to, $auth_data){
     133    if (method_exists('SWPM_SL_Utils', 'log_simple_debug')) {
     134        SWPM_SL_Utils::log_simple_debug("After login redirection addon. Checking if member need to be redirected.", true);
     135    }
     136
     137    $swpm_member = SwpmMemberUtils::get_user_by_email($auth_data->email);
     138
     139    if (empty($auth_data->referer_url)) {
     140        return $redirect_to;
     141    }
     142
     143    //First check if a the swpm_redirect_to argument is set (meaning the user needs to be redirected to the last page).
     144    $query_string = parse_url($auth_data->referer_url, PHP_URL_QUERY);
     145    if (!empty($query_string)) {
     146        parse_str($query_string, $query_params);
     147        if(isset($query_params['swpm_redirect_to']) && wp_http_validate_url($query_params['swpm_redirect_to'])){
     148            return esc_url_raw($query_params['swpm_redirect_to']);
     149        }
     150    }
     151
     152    //Check if there is a membership level specific after login redirection
     153    $level_id = $swpm_member->membership_level;
     154    $key = 'swpm_alr_after_login_page_field';
     155    $after_login_page_url = SwpmMembershipLevelCustom::get_value_by_key($level_id, $key);
     156    if (!empty($after_login_page_url)) {
     157        //Redirect to the membership level specific after login page.
     158        if (method_exists('SWPM_SL_Utils', 'log_simple_debug')) {
     159            SWPM_SL_Utils::log_simple_debug("After login redirection is configured in the membership level. Redirecting to: " . $after_login_page_url, true);
     160        }           
     161        return $after_login_page_url;
     162    }
     163
     164    return $redirect_to;
     165}
     166
    131167function swpm_alr_after_login_url($url) {
    132168    $auth = SwpmAuth::get_instance();
Note: See TracChangeset for help on using the changeset viewer.