• Hello,

    I’m pretty sure it should be some basic problem, as hundreds sites should use same configuration as I’m trying to. But I can’t find any discussions on issue I have.

    Problem:
    I’m trying to use some of multilanguage plugins, who enables a subdomain-per-language configuration. For example example.com, en.example.com, fr.example.com.
    Unfortunately the Social Login generates single constant for all redirects (without subdomain): example.com/wp-content/plugins/wordpress-social-login/hybridauth/?hauth.start=Google
    as result, when user logs in from en.example.com, session cookie set on en.example.com is lost. As result the hybridauth page renders an error “406. The session identifier is missing.”

    Checked sources, and as far as I understand (I’m not a php-developer), on startup it generates single constant for further use:
    define( ‘WORDPRESS_SOCIAL_LOGIN_ABS_PATH’, plugin_dir_path( __FILE__ ) )
    define( ‘WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL’, plugin_dir_url( __FILE__ ) )
    define( ‘WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL’, WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL . ‘hybridauth/’ )

    As far as I understand, the problem can be fixed if Social Login plugin doesn’t use constants, but build these urls on each request, based on current domain, or modified by multilanguage plugins ‘site_url’.

    Correct me if I’m wrong.
    How do others use Social Login plugin in multidomain environment?
    Or even how can I use it in simplest case: example.com vs http://www.example.com? Or may be I’m complicating the problem, and solution is much simpler? Anything to do with cookies policies?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ai91

    (@ai91)

    Okay, seems I’ve found some workaround solution in the WPSL issue tracker:
    https://github.com/miled/wordpress-social-login/issues/201

    not really what I expected to be used as solution, but works for me.

    Thread Starter ai91

    (@ai91)

    Update: ended up with introducing own solution.
    The workaround with native php session works, but not really nice: the Social Login plugin successfully logs in, but redirect url always points to main domain, without any subdomains (used WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL constant, which is always on main domain, as result on successful login browser was redirected to same domain).

    To solve the issue, replaced WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL and WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL constants with own functions, which build urls dynamically, based on current HOST. :

    homeurls.php
    ===========================

    <?php
    function wsl_plugin_url()
    {
    	$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? 
    		"https://" : "http://";
    	$domainName = $_SERVER['HTTP_HOST'];
    	
    	$plugin_url = plugin_dir_url( __FILE__ );
    	$plugin_path = parse_url($plugin_url, PHP_URL_PATH);
    	return $protocol.$domainName.$plugin_path;
    }
    
    function wsl_hybridauth_url()
    {
    	$hybridauth_url = wsl_plugin_url() . 'hybridauth/';
    	return $hybridauth_url;
    }

    ================================

    then replaced all constants usages with

    require_once WORDPRESS_SOCIAL_LOGIN_ABS_PATH . "homeurls.php";
    ... wsl_hybridauth_url() ... instead of  WORDPRESS_SOCIAL_LOGIN_HYBRIDAUTH_ENDPOINT_URL 
    ... wsl_plugin_url() ... instead of  WORDPRESS_SOCIAL_LOGIN_PLUGIN_URL 

    Now I don’t need the native session support. And user becomes logged in domain he uses.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Multidomain support’ is closed to new replies.