latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

login widget shows logedin on other subdomain

Home Forums Community Forum login widget shows logedin on other subdomain

Tagged: 

This topic contains 4 replies, has 4 voices. Last updated by  Raam Dev 4 years, 5 months ago.

Topic Author Topic
Posted: Wednesday Jul 25th, 2012 at 8:44 pm #20249

List Of Topic Replies

Viewing 4 replies - 1 through 4 (of 4 total)
Author Replies
Author Replies
Posted: Thursday Jul 26th, 2012 at 2:56 am #20282

Hi Roland.

The file you’re looking for is: s2member-pro\includes\classes\login-widget.inc.php

Login sessions are handled by WordPress. The widget uses [hilite mono]is_user_logged_in[/hilite] to check that. http://codex.wordpress.org/Function_Reference/is_user_logged_in

Here’s a thread related to the widget and multisite, that you may find interesting too: http://www.s2member.com/forums/topic/login-widget-on-multisite/

I hope that helps. :)

Posted: Thursday Jul 26th, 2012 at 5:57 am #20300

I can’t replicate this on MS installs with unique domain names for sub directory/domains.

Perhaps its a cookie issue?

Will you be using the same top level domain for all sites?

Posted: Thursday Jul 26th, 2012 at 9:48 pm #20353

here is what I learned and how I fixed.
the pro login widget checks only if a user is a member of the wordpress network. It does not check if a user is a member of the current blog. So here is how I came up with a solution without changing any of the code of the s2member.

I placed the bellow in the sidebar.php for my theme

<?php 
    if(is_user_logged_in()) {   										// check if the user is logged in because he is a member of the network
		global $current_user;
		get_currentuserinfo();
		if ( is_user_member_of_blog( $current_user->ID ) ) { 			// check if this user is a member of this blog
			echo s2member_pro_login_widget();							// if he is, show the login box which will show the profile links and gavatar since user is logged in.
		} else {
			echo 'You are NOT a member of this blog go to your blog.';	// if he is not, let him know to go back to the blog where he is a member of
			$dc_blogs = get_blogs_of_user( $current_user->id );			// get all the blogs he is a member of
			if($dc_blogs) {
				foreach ( $dc_blogs as $dc_blog ) {						// list a nice link for the blogs he is a member of
					echo '<li><a href="http://' . $dc_blog->domain . $dc_blog->path .'">' .  $dc_blog->blogname . '</a></li>';
				}
			}
		}
	}
    else if(is_user_not_logged_in()) 									// if user not logged in, show the login box
		echo s2member_pro_login_widget();
?>		
		

let me know if you guys have a more elegant solution.
Always looking for more efficient code.

Posted: Saturday Jul 28th, 2012 at 1:11 am #20483
Raam Dev
Username: Raam
Staff Member

Hi Roland,

Thank you very much for sharing your solution! :)

~Awarded Roland Kedikian the Helpful badge.
Viewing 4 replies - 1 through 4 (of 4 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.