We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28407
    • 20 Posts
    Hello, i’m building my website, and i have a problem with login/logout for users: WebLogin works fine, but it don’t want works correct with utf8 encoding, so i can’t use it, because my site is not on english; WebLogonPE is good enough, but i think he have too much bugs, maybe later it will be great snippet. So all what i want is to use login/logout/register forms from my Simple Machine Forum. It is fully integrated to my website, im using SMF module for Modx. Any ideas how to integrate this forms?
      • 31800
      • 10 Posts
      Hmmm... I made the integration some time ago, then abandoned it in order to make user management with WebLoginPE. But now, after severall hours of fight (WLPE does not want to cooperate with SMF in field of registration) I’m going to get back to SMF login idea, so if I find my previous work, I’ll post it here.

      EDIT: Ok, this is what I have by now:

      Snippet displaying login/logout form:
      <?php
      
      require_once($modx->config['base_path'].'/path/to/smf/SSI.php');
      global $context, $scripturl, $user_info;
      
      $_SESSION['login_url'] = 'http://yoursite.net' . $_SERVER['PHP_SELF'];
      $_SESSION['logout_url'] = 'http://yoursite.net' . $_SERVER['PHP_SELF'];
      
      // not logged
      if($context['user']['is_guest'])
      {
      	$_SESSION['old_url'] = $modx->makeUrl($modx->documentIdentifier,'','','full');
      	echo '<p><form action="'.$scripturl.'?action=login2" method="post" accept-charset="'.$context['character_set'].'"><input type="text" id="user" name="user" value="'.$user_info['username'].'" /><input type="password" name="passwrd" id="passwrd" /><input type="hidden" name="cookielength" value="-1" /><input type="submit" value="Zaloguj" /><br /><label><a href="'.$scripturl.'?action=register">Register</a> or <a href="'.$scripturl.'?action=reminder">resend password</a>.</label></form></p>';
      }
      // logged
      else
      {
      	echo '<p>Welcome, <strong>'.$context['user']['name'].'</strong>! New messages: <strong><a href="'.$scripturl.'?action=pm">'.$context['user']['unread_messages'].'</a></strong><br />';
      	$_SESSION['old_url'] = $modx->makeUrl($modx->documentIdentifier,'','','full');
      	echo '<a href="'.$scripturl.'?action=profile">Edit profile</a> | <a href="'.$scripturl.'?action=logout;sesc='.$sc.'">Logout</a></p>';
      }
      ?>

      Unfortunatelly redirection after logging in/out does not work for me and I have no idea how to fix it. Anyone?


      This is PHx modifier with which you can display some user data:
      <?php
      require_once($modx->config['base_path'].'/path/to/smf/SSI.php');
      global $context;
      
      switch($options)
      {
      	case 'uname':	return $context['user']['username'];
      	case 'uid':		return $context['user']['id'];
      	case 'name':	return $context['user']['name'];
      	case 'email':	return $context['user']['email'];
      	case 'url':		return $context['user']['url'];
      	case 'urlname':	return $context['user']['urlname'];
      	case 'messages':return $context['user']['messages'];
      	case 'unread':	return $context['user']['unread_messages'];
      	case 'uid':		return $context['user']['id'];
      	default: return 'p';
      }
      ?>

      That’s all and I know it’s really simple, but maybe also helpful to some extent. Made for SMF 1.1.6 so I don’t know how it behaves in case of SMF 2.x