1
grams79
Login / dropdown select with current members
  • 2009/1/26 5:21

  • grams79

  • Just popping in

  • Posts: 7

  • Since: 2009/1/26


My first post here.
I would like to say that XOOPS is great. Thank you.

Here is my question if anyone would like to give some tips.
I would like to replace the text field "uname" with a select field that would have the registared member's username in the list.
And also a little extra code for replacing the usernames with the member's real name.

The part that I am having trouble with is how to go about this from the point of creating a script that calls the member usernames...
I'm thinking now that instead of usernames it would probebly end up being the user IDs in numbers.

Well... I'll check back later and maybe I will have someone to help me work this out.

2
ghia
Re: Login / dropdown select with current members
  • 2009/1/26 8:11

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


grams79, welcome on the XOOPS forum!

What version of XOOPS do you have?
About which lists are you talking?
In some modules as eg News, there are preferences to show the real name instead of the username (uname) for the author of the article.

3
grams79
Re: Login / dropdown select with current members
  • 2009/1/26 16:40

  • grams79

  • Just popping in

  • Posts: 7

  • Since: 2009/1/26


Thank you for the reply ghia.

My version is 2.3 and it would be the registered members list.


I've got my XOOPS site closed and manually add members.

The usernames are sometimes 30 characters long.

And yes, just like in News and Forums the option to use the "real name" instead.

I've used that option in every module, even did some manual scripting to fix other modules.


This is slightly important for me to complete for my members.

There are many of them and for each to type in usenames such as "Gali_Gallionarona" is a bother for most.

The user would see the "real name" after login as "Gali Gallionarona" without the underscore threw-out the site.

The field selection of member names would also have to be alphabetical.


I'm thinking this would have to be done with a team effort of javascript and php...

How about the "foreach" method that I see in most of the XOOPS scripting?


Script to start with I guess...
<form action="/user.php" method="post">

Username:
<
select name="uname">
<
option value="UID1">REAL NAME</option>
<
option value="UID2">REAL NAME</option>
<
option value="UID3">REAL NAME</option>
<
option value="UID4">REAL NAME</option>
</
select>

Password: <input type="password" name="pass" size="12" />

<
input type="hidden" name="xoops_redirect" value="/" />
<
input type="hidden" name="xoops_login" value="1" />
<
input type="submit" value="User Login" />
</
form>


4
grams79
Re: Login / dropdown select with current members
  • 2009/1/27 18:58

  • grams79

  • Just popping in

  • Posts: 7

  • Since: 2009/1/26


Am I on the right track??

$xoopsid_select = new XoopsFormSelectUser(_PROFILE_AM_SELECTUSER'id');
$form->addElement($xoopsid_select);


I understand that I am missing many things... such as include once php files... but I know it has something to do with the XoopsFormSelectUser.

Been searching threw system/admin/users to find out how to duplicate the select field of members and add it to the login form.

Back to tinkering around I guess...

5
grams79
Re: Login / dropdown select with current members
  • 2009/2/2 22:59

  • grams79

  • Just popping in

  • Posts: 7

  • Since: 2009/1/26


I got it working.

Created a module and here is my code.

myLogin/xoops_version.php
<?php
$modversion
['name'] = "myLogin";
$modversion['version'] = 1.0;
$modversion['image'] = "logo.png";
$modversion['dirname'] = "myLogin";
$modversion['hasAdmin'] = 0//
$modversion['adminpath'] = "";
$modversion['hasMain'] = 1;
$modversion['templates'] = array();
$modversion['templates'][1]['file'] = 'login.html';
$modversion['templates'][1]['description'] = '';
?>


myLogin/index.php
<?php
include(XOOPS_ROOT_PATH."/header.php");
if ( !
$xoopsUser ) {

$xoopsTpl->assign('xoops_pagetitle''Login');

    include_once 
XOOPS_ROOT_PATH "/class/xoopsformloader.php";
    
$myLogin = new XoopsForm('''myLogin''login.php''post'true);
    
$to_username = new XoopsFormSelectUser('''user_select');
    
$xoopsTpl->assign('to_username'$to_username->render());
    
$myLogin->assign($xoopsTpl);
    
$xoopsTpl->display("db:login.html");

$result $xoopsDB->query("SELECT count(*) from ".$xoopsDB->prefix("users").""); list($numbers) = $xoopsDB->fetchRow($result);

}else{

echo 
"Your Logged In";

}

include(
XOOPS_ROOT_PATH."/footer.php");
?>


myLogin/login.php
<?php
include("../../mainfile.php");
include(
XOOPS_ROOT_PATH."/header.php");
$xoopsTpl->assign('xoops_pagetitle''Login 2');

$uid $_POST['user_select'];

    
$member_handler =& xoops_gethandler('member');
    
$thisUser =& $member_handler->getUser($uid);

$uavatar $thisUser->getVar('user_avatar');
$show_uname $thisUser->getVar('uname');
$show_name $thisUser->getVar('name');
$show_uavatar XOOPS_URL.'/uploads/'.$uavatar;
?>

<div style="font-size:x-large;">
You have chosen <img src="<?php echo $show_uavatar?>" width="32" height="32"> <?php echo $show_name?>.
</div>

<br />

<form action="../../user.php" method="post">
<input type="hidden" name="op" value="login" />
<input type="hidden" name="xoops_redirect" value="" />
<input type="hidden" name="uname" value="<?php echo $show_uname?>" />
Add password:  <input type="password" name="pass" size="21" maxlength="32" /> <input type="submit" value="Agree, login with <?php echo $show_name?>" /> <a href="javascript:history.go(-1)">Choose again.</a>
</form>

<?php
include(XOOPS_ROOT_PATH."/footer.php");
?>


myLogin/templates/login.html
<form name="<{$myLogin.name}>" id="<{$myLogin.name}>" action="<{$myLogin.action}>" method="<{$myLogin.method}>" <{$myLogin.extra}> >
Choose: <{$to_username}> <input type="submit" value="Continue" />
</
form>


If anyone can make this code work faster with less effort please modify and enjoy.


6
grams79
Re: Login / dropdown select with current members
  • 2009/2/8 15:56

  • grams79

  • Just popping in

  • Posts: 7

  • Since: 2009/1/26


I'm happy to see that everyone here in the XOOPS community are so busy helping everyone.
It seems odd that most of the new member issues are ignored... do we need 1000 posts to be noticed?

This thread should have been moved to another area be now..... or at least peaked someone's interests...

*listens for crickets*

7
ghia
Re: Login / dropdown select with current members
  • 2009/2/8 18:56

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
It seems odd that most of the new member issues are ignored...

No, I don't think that is true.
Quote:
do we need 1000 posts to be noticed?
Absolutly not!
It requires only someone who is interested in the same feature as you or can say something meaningfull about the problem you have.

For this thread, it seems you are very capable(!) and have no problems left(?).
I noticed only one thing in your code that wonders me (didn't try) and that is a missing(?)
include("../../mainfile.php");

in myLogin/index.php .

8
trabis
Re: Login / dropdown select with current members
  • 2009/2/8 19:22

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Hi,
You can easily hack system module to achieve that.

Open user.php around line 71:
$xoopsOption['template_main'] = 'system_userform.html';
        include 
'header.php';
        
$xoopsTpl->assign('lang_login'_LOGIN);
        
$xoopsTpl->assign('lang_username'_USERNAME);
        if (isset(
$_GET['xoops_redirect'])) {
            
$xoopsTpl->assign('redirect_page'htmlspecialchars(trim($_GET['xoops_redirect']), ENT_QUOTES));
        }
        if (
$xoopsConfig['usercookie']) {
            
$xoopsTpl->assign('lang_rememberme'_US_REMEMBERME);
        }
        
$xoopsTpl->assign('lang_password'_PASSWORD);
        
$xoopsTpl->assign('lang_notregister'_US_NOTREGISTERED);
        
$xoopsTpl->assign('lang_lostpassword'_US_LOSTPASSWORD);
        
$xoopsTpl->assign('lang_noproblem'_US_NOPROBLEM);
        
$xoopsTpl->assign('lang_youremail'_US_YOUREMAIL);
        
$xoopsTpl->assign('lang_sendpassword'_US_SENDPASSWORD);
        
$xoopsTpl->assign('mailpasswd_token'$GLOBALS['xoopsSecurity']->createToken());
        
        
//hack by trabis
        
include_once XOOPS_ROOT_PATH "/class/xoopsformloader.php";
        
$users_form = new XoopsFormSelect('''uname'01false);
        
$sql "SELECT uid, uname FROM " $xoopsDB->prefix('users') . " ORDER BY uname ASC";
        
$result $xoopsDB->query($sql);
        
$users_array = array();
        while (
$myrow $xoopsDB->fetchArray($result)) {
            
$users_array[$myrow['uname']] = $myrow['uname'];
        }
        
$users_form->addOptionArray($users_array);
        
$xoopsTpl->assign('users_form'$users_form->render());
        
// end of hack
        
        
include 'footer.php';
        exit();


Then open system/templates/system_userform.html and replace by this:
<fieldset style="padding: 10px;">
  <
legend style="font-weight: bold;"><{$lang_login}></legend>
  <
form action="user.php" method="post">
    <{
$lang_username}> <{$users_form}><!-- HACK IS HERE--> <br /><br />
    <{
$lang_password}> <input type="password" name="pass" size="21" maxlength="32" /><br /><br />
    <{if isset(
$lang_rememberme)}>
        <
input type="checkbox" name="rememberme" value="On" checked /> <{$lang_rememberme}><br /><br />
    <{/if}>
    
    <
input type="hidden" name="op" value="login" />
    <
input type="hidden" name="xoops_redirect" value="<{$redirect_page}>" />
    <
input type="submit" value="<{$lang_login}>" />
  </
form>
  <
br />
  <
a name="lost"></a>
  <
div><{$lang_notregister}><br /></div>
</
fieldset>

<
br />

<
fieldset style="padding: 10px;">
  <
legend style="font-weight: bold;"><{$lang_lostpassword}></legend>
  <
div><br /><{$lang_noproblem}></div>
  <
form action="lostpass.php" method="post">
    <{
$lang_youremail}> <input type="text" name="email" size="26" maxlength="60" />&nbsp;&nbsp;<input type="hidden" name="op" value="mailpasswd" /><input type="hidden" name="t" value="<{$mailpasswd_token}>" /><input type="submit" value="<{$lang_sendpassword}>" />
  </
form>
</
fieldset>


If you are using profile module then you need to adapt this hack.

9
grams79
Re: Login / dropdown select with current members
  • 2009/2/16 15:56

  • grams79

  • Just popping in

  • Posts: 7

  • Since: 2009/1/26



Yes, I am using the PROFILE module.

That is what I was looking for... someone else to understand my needs. lol
Thanks so much Trabis.

Thank you XOOPS community!

Login

Who's Online

99 user(s) are online (82 user(s) are browsing Support Forums)


Members: 0


Guests: 99


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits