Get Joomla User Email address - Post...

User 2338370 Photo


Registered User
11 posts

Hi Folks,
I am using WFB 2.4.5318. I have a drop-down box with user names (manually populated).
These users are all registered Joomla users (can't access the form otherwise).

I would like to send a confirmation email to the user who filled out the form, but I dont want them to have to manually select or to enter their email address ------- it is already in the Joomla Users table.
How can I get this email and put it into the return email for the form, so that the user gets a copy (without having to enter their email address).
Hope that made sense... I have looked through the forum, but cant find anything related to this question.

TIA,
Mike
User 187934 Photo


Senior Advisor
20,188 posts
Online Now

I don't use Joomla but I do what your requesting on one site with the form builder.
Try setting up your dropdown like this.
<div class="fb-item fb-100-item-column" id="item1">
<div class="fb-grouplabel">
<label id="item1_label_0" style="display: inline;">Select an email address</label>
</div>
<div class="fb-dropdown">
<select name="email" id="item1_select_1" required data-hint="">
<option id="item1_0_option" selected value="">
<?php $user = JFactory::getUser();
echo $user ; ?>
</option>
</select>
</div>
</div>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2338370 Photo


Registered User
11 posts

Hi Eric...
thanks for your reply.
I wonder could you give me a little more information? I am not sure of how and where to put the code you suggested.
What I have done is this............

In the form settings, under Email Notices, Auto-Response Message, I need to enter a field for the response email address.
I can only enter this in the settings if I have an email field on the form, so I have added this field to the form, and called it "Email".
I want to automatically populate this with the Joomla user email address.
I have tried putting this code below into the form HTML file, as the first lines, but I cant get it to work. Can you possibly suggest where I am going wrong? Do I need to specify the database table and prefix?

Thank you for your time if you can help me in this...... if not, I will understand perfectly........ this is all due to my own ignorance, and I am coming to grips to overcome this :-) :-) :-)

Mike

The code I have put into the form HTML is this;
<?php
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);

if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}

if (file_exists(__DIR__ . '/defines.php'))
{
include_once __DIR__ . '/defines.php';
}

if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}

if (!defined('_JDEFINES'))
{
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}

require_once JPATH_BASE.'/includes/framework.php';

$user = JFactory::getUser();
// echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is {$user->username}</p>";
Email = $user->email;
?>

User 187934 Photo


Senior Advisor
20,188 posts
Online Now

As I said I don't use Joomla but did look at their help files to give you an idea of what was needed. It looks as if you have a handle on the general idea. I would ask on a Joomla forum what is needed to get it working.:)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2338370 Photo


Registered User
11 posts

Thanks for your replies Eric....
I will stick at it.

Mike
User 10077 Photo


Senior Advisor
1,095 posts

queeg wrote:
How can I get this email and put it into the return email for the form, so that the user gets a copy (without having to enter their email address).

If it doesn't matter if the email address actually appears on the form, here is one method that works for me at
http://candle-fundraising.org/fundraise … ndraising/

Though I've not used Joomla, I suspect that either (1) the user email is stored in a cookie, (2) the user id is the user's email and is stored in a cookie, or (3) the user id is stored in a cookie which you can use to query the database for the email.

You can set any field on the form as the address for the confirmation. Therefore, create a hidden field in the form options, call it [confirmemail] and use that for the confirmation. (I'm assuming that WFB can use a hidden field for the confirmation email address as well as a visible one.

If #1 or #2 are true, you should be able to extract the email from the cookie. Edit the hidden field value on the WFB exported form. Make that value the exported cookie.

If #3 is true, extract the id from the cookie, query the database for the user email, then edit the hidden field as described above.

The only downfall of this method would be if you want to give the user the opportunity to put in a different email address.
ASK ME ANYTHING
I provide personalized help for Coffeecup Users including personal or group training for Site Designer, Web Form Builder and more via Zoom.
Email me at support@uscni.org or call 865-687-7698.

Did you know that Web Form Builder can be used for both simple and complicated forms and that it's not limited to the default fonts and buttons? Take a look at a form we developed for WindowTinting.com.
https://forms.windowtinting.com/forms/w … ppingcart/

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.