×

Notice

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

TOPIC: Allowing users to enter their email address

Allowing users to enter their email address 13 years 9 months ago #10042

  • cedc
  • cedc's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
I am helping with a site that shares a login among a number of users. How can I allow/force them to type their email address when they make a comment? The email address associated with the username isn't relevant, I'd like them to have to type it manually.

Allowing users to enter their email address 13 years 9 months ago #10045

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey Cedc,
Thank you for your purchase!
Are you talking about registered users or unregistered?

As you know - if the user is registered then we use the e-mail that he provided during registration.

If it is about anonymous comments, then the only way would be js.

Can you explain me what you are trying to do exactly :)
Cheers,
Daniel

Allowing users to enter their email address 13 years 9 months ago #10046

  • cedc
  • cedc's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
This is for registered users. This site shares one account among multiple people (for a variety of reasons that I won't get into here). I'd like to be able to provide them a space to enter their email address, disregarding the email that is associated with this shared Joomla account. I realize I may need to hack a bit but I'm hoping for some guidance.

Allowing users to enter their email address 13 years 9 months ago #10047

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Ok, so what do you think about this. Normally the email field for registered users is grayed out and we have automatic in it. Do you want to enable this field for writing again?

Allowing users to enter their email address 13 years 9 months ago #10048

  • cedc
  • cedc's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
Yes, that sounds right for our purposes. Thanks for your help!

Allowing users to enter their email address 13 years 9 months ago #10051

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey cedc,
the whole thing was easier than expected for me :D
So first go to compojoomcomment's template open the index.php file and find
<input name='temail' id="temail" type='text' value='{email}' tabindex="2" {registered_readonly}/>
change it in
<input name='temail' id="temail" type='text' value='{email}' tabindex="2" />

then go to components/com_comment/classes/joomlacomment/JOSC_form.php
function set_temail($value) {
		$user = JFactory::getUser();
$this->_temail = ($user->id ? JText::_('JOOMLACOMMENT_AUTOMATICEMAIL') : $value); /* change also modify - ajax_quote ! */
	}

and change it to
function set_temail($value) {
		$this->_temail = '';
	}

and last but not least go to components/com_comment/joscomment/jscripts/client.js and change
	if(typeof(form.temail) != 'undefined') {
		if(form.temail.value != '' && !form.temail.disabled) {
			if (!validate(form.temail.value, form)) {
				return 0;
			}
		}
	}

to
	if(typeof(form.temail) != 'undefined') {
			if (!validate(form.temail.value, form)) {
				return 0;
			}
	}

the last thing will ensure that the user will have to always provide an e-mail address to submit the comment.
Cheers,
Daniel

P.S. Don't forget to write a review at extensions.joomla.org/extensions/contact...icles-comments/12259

Allowing users to enter their email address 13 years 9 months ago #10052

  • cedc
  • cedc's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
Amazing! Thanks so much!

Allowing users to enter their email address 13 years 9 months ago #10080

  • cedc
  • cedc's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
Update: I am informed that it is not saving the manually input names/emails even though it allows the users to input them. It still saves the names/emails associated with the Joomla account.

Any ideas where else I could look?

Allowing users to enter their email address 13 years 9 months ago #10082

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
I think that I know from where the problem is coming
go to components/com_comment/joomlacomment/JOSC_board.php
find function decodeURI (line 495)
and in this function you will see
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 = JOSC_utils::decodeData('tname');
			$this->_temail = JOSC_utils::decodeData('temail');
		}
change it to
if ($user->username) {
			$this->_userid = $user->id;
			$this->_usertype = $user->usertype;
			$this->_tname = JOSC_utils::decodeData('tname');
			$this->_temail = JOSC_utils::decodeData('temail');
		} else {
			$this->_userid = 0;
			$this->_usertype = 'Unregistered';
			$this->_tname = JOSC_utils::decodeData('tname');
			$this->_temail = JOSC_utils::decodeData('temail');
		}

This should do the trick. If it doesn't work let me know I'll test it myself :)

Allowing users to enter their email address 13 years 9 months ago #10083

  • cedc
  • cedc's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 9
  • Thank you received: 0
Yes, this seems to work. Thanks again!

And in the off chance that anyone else needs this modification, I also figured out how to make the name and title (in my case, title has been renamed as "Country" in the language files) required entries:

In the language file, I added two more variables:
JOOMLACOMMENT_FORMVALIDATE_NAME=Please insert your name.
JOOMLACOMMENT_FORMVALIDATE_TITLE=Please insert your country.

In the javascript file you reference above (components/com_comment/joscomment/jscripts/client.js) I added these lines after the one that makes the email required:
    if (form.ttitle.value == '' ) {
        alert(_JOOMLACOMMENT_FORMVALIDATE_TITLE);
        return 0;
    }
    if (form.tname.value == '' ) {
        alert(_JOOMLACOMMENT_FORMVALIDATE_NAME);
        return 0;
    }

Allowing users to enter their email address 13 years 9 months ago #10084

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
I'm happy that it is working.
As usual I just would like to remind you and everyone else to write a review here:
extensions.joomla.org/extensions/contact...icles-comments/12259
If possible of course!
Cheers,
Daniel
  • Page:
  • 1
Time to create page: 0.133 seconds