×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Any way to let registered users input a name?

Any way to let registered users input a name? 16 years 3 months ago #488

  • Min Yoo
  • Min Yoo's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
I know this is a strange question, but is there a way to let users that are logged in to input a different name and require an e-mail address when adding comments? It's grayed out when you are logged in (I realize this is to keep people from pretending they are someone else). Basically, I'd like to treat them like they are unregistered

The site I'm working on does not really have multiple registered users, except there is one login that is used by many people to access a few hidden/protected pages. So we could potentially have hundreds of comments from that one registered user, when really they are from many different people, and we don't know who.

If not, any ideas on how I might make something work for my situation? My client doesn't want to have multiple individual user accounts at this time.

Thanks for any thoughts on this,
Min

Any way to let registered users input a name? 16 years 3 months ago #490

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Do you know any php?

Any way to let registered users input a name? 16 years 3 months ago #494

  • Min Yoo
  • Min Yoo's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
Thanks for the quick response!
A little. I can find my way around a little php code. I couldn't write a module, but I've stuck in many a small hack here and there to get modules to do what I need. Is there hope for my case?
Thanks,
Min

Any way to let registered users input a name? 16 years 3 months ago #496

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Ok, I will give you the hints.

Go to joscomment/comment.class.php

find the function decodeURI() and find the following lines:
if ($my->username) {
	        $this->_userid = $my->id;
            $this->_usertype = $my->usertype;
            $this->_tname = $my->username;
            $this->setUser();
        } else {
	        $this->_userid = 0;
        	$this->_usertype = 'Unregistered';   
	        $this->_tname = $this->decodeData_Charset('tname');
    	    $this->_temail = $this->decodeData_Charset('temail');
        }

and change it to:
//if ($my->username) {
	        $this->_userid = $my->id;
            $this->_usertype = $my->usertype;
        //    $this->_tname = $my->username;
      //      $this->setUser();
    //    } else {
//	        $this->_userid = 0;
//        	$this->_usertype = 'Unregistered';   
	        $this->_tname = $this->decodeData_Charset('tname');
    	    $this->_temail = $this->decodeData_Charset('temail');
  //      }
So it will be possible for you to input a different name and it will be saved to the database.
The Problem is that the user_id is taken for the output and that is why it will be written the user_name that posted the comment. I suppose that the setUser function is making the output, but I'm not 100% sure and right now I don't have the time to test. Try to find the way, if not just wirte.

Any way to let registered users input a name? 16 years 3 months ago #500

  • Min Yoo
  • Min Yoo's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 0
Thank you for your direction! it is exactly what I needed.
This is what I did:

1. In function decodeURI(), I did something slightly different than your suggestion, but same idea
//jmw-commenting out setting username and e-mail
        if ($my->username) {
	        $this->_userid = $my->id;
            $this->_usertype = $my->usertype;
            //$this->_tname = $my->username;
            //$this->setUser();
        } else {
	        $this->_userid = 0;
        	$this->_usertype = 'Unregistered';   
	        //$this->_tname = $this->decodeData_Charset('tname');
    	    //$this->_temail = $this->decodeData_Charset('temail');
        }
 
// jmw-adding next 2 lines to allow setting name and e-mail in ALL situations.		
	$this->_tname = $this->decodeData_Charset('tname');
    	$this->_temail = $this->decodeData_Charset('temail');

2. In function setUser(), I made one line change:
	   // jmw-rewrite following line to show name, not login username
           //$this->_item['name']     = $this->_use_name ? $user['name'] : $user['username'];
          $this->item['name'] = $user['name'];
 
By the way, I tried just setting the use name parameter but then it used the name set for the login instead of the name for the comment. So, I made this change, and it displayed the name the commenter input.

3. In function set_tmail(), I made the following change:
	//jmw-setting to $value no matter what
        //global $my;
        //$this->_temail = ($my->id ? _JOOMLACOMMENT_AUTOMATICEMAIL : $value); /* change also modify - ajax_quote ! */
	$this->_temail = $value;

I also turned off the {editbuttons} in the template so that people couldn't edit other people's comments since they use the same login.
Please let me know if I did anything "dangerous".
Thanks again for your prompt and helpful advice!
-Min

Any way to let registered users input a name? 15 years 7 months ago #3722

  • Dag Ove Hoel
  • Dag Ove Hoel's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
I tried doing this, and I could get the original reply to work. Not your solution Min Yoo...

Anyways. My code looks like this:
function decodeURI()
    {
	$user =& JFactory::getUser();
 
	$this->_request_uri = JArrayHelper::getValue( $_SERVER, 'REQUEST_URI', '' ); // _JOSC_MOS_ALLOWHTML
	$this->_josctask = $this->decodeData_Charset('josctask');
 
	//if ($user->username) {
	    //$this->_userid = $user->id;
	    $this->_usertype = $user->usertype;
	    //$this->_tname = $user->username;
	    //$this->setUser();
	//} else {
	    $this->_userid = 0;
	    //$this->_usertype = 'Unregistered';
	    $this->_tname = $this->decodeData_Charset('tname');
	    $this->_temail = $this->decodeData_Charset('temail');
	//}

The registered user can now write their own name, and it still saves it as user id 0. The same as if an anonymous user would post a comment.

Although, I cannot seem to remove the initial text "automatic" in the e-mail field. Where can I have this removed? When writing I can still write my own email, but since the text "automatic" is already there I doubt that people would understand that they need to type their email as well...

Any way to let registered users input a name? 15 years 7 months ago #3725

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
well, if everyone should enter differen username and e-mail, why just not enable accounts for everyone? It is stupid to have 1 account for 20 persons - nobody knows what, where and who is doing something.

Any way to let registered users input a name? 15 years 7 months ago #3727

  • Dag Ove Hoel
  • Dag Ove Hoel's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
nah.... the password is kind of a "login to access restriced". mainly for my friends and people i trust. then they can give the passwd to their friends again and so on.... dont want user accounts. people wont remember passwd or login. not for this website. on a different website, sure. i have sever websites where its better with separate user accounts. but not this one....

i might as well remove the email field. dont really care. so if you know how to hide it instead then i can do that....

Any way to let registered users input a name? 15 years 7 months ago #3728

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
I must look in the code - of course there is a way to let the user input an e-mail.
The thing is. If several people should have access to your webpage - then everyone needs a separate account.

If this is a site for your friends, then you can protect it with htpassword - everyone who know the password will be able to access your site and you won't have to control the users through joomla. They will not have to register and will have access to all the information.

For me this is a better decision - htpassword and no joomla accounts. This way the users will be guests and they will input the information you request.

Any way to let registered users input a name? 15 years 7 months ago #3729

  • Dag Ove Hoel
  • Dag Ove Hoel's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
sorry mate ;)

htpasswd won't work. i have some articles that are for restricted, and some that are public. so just htpasswd wont be sufficient....

can i maybe hide the email field in the template?

Any way to let registered users input a name? 15 years 7 months ago #3731

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Obama says: "Yes, we can!". I say: "Yes, you can :)"
compojoom.com/faq/20-how-to-hide-a-field-in-the-templates.html

But again - start with creating accounts for all your friends, instead of using just one.

Any way to let registered users input a name? 15 years 7 months ago #3744

  • Dag Ove Hoel
  • Dag Ove Hoel's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 0
Excellent!
Thank you :)
  • Page:
  • 1
Time to create page: 0.155 seconds