XF 2.2 Can we add our user's email addresses to their profile?

Mikethemix

Active member
We are considering how to react to the Online Protection Act 2023.
Our forum is very small and for members only (no public access).
We are considering stopping Conversations (DM) to improve our OPA Risk Assessment.
Our users would then have to use email to contact each other direct (which should be OK but inconvenient).
It would be very convenient if we could add email addresses to User Profiles, then users would not need to consult a members list, simply click on a members profile and email link...

How can that be done (for all members)?
 
Absolutely, if ours was a public access forum.
However it is a "club members only" private forum - accessible only to users who are logged in.
All registered users are members of our old car club and have paid a subscription.
 
  • Like
Reactions: FTL
Right, I getcha, no visiblity without logging in.

I suggest making a really clear announcement and giving it a couple of weeks before going live with it to give people time to opt out.
 
Good idea on announcement.
My question is really HOW can we add their email address to their profile automatically (so all our member's profiles would show their email address - or a link to it)?
 
Last edited:
I remember vBulletin (4) had a feature where users can choose PM and/or email contact. The email contact was via a contact form so no email was visible to other users, just a link to the form.

I would have thought there should be such an addon for XenForo? if not there should be.
 
My question is really HOW can we add their email address to their profile automatically (so all our member's profiles would show their email address - or a link to it)?
Even though it's not a public forum I think you'd have huge privacy concerns if you made all members emails available to other members without them opting in.
 
I think you'd have huge privacy concerns if you made all members emails available to other members without them opting in.

Thanks for your concerns on this simple idea. However, we already have their approval. As part of preparing for GDPR, our members agreed to share contact details via a club membership list - which is published to all members (and has been for 75 years!). An online version of that list is already on our forum and well appreciated by members.

So, back to my question - How could we do it? Any ideas?
 
Last edited:
That's an excellent suggestion Ozzy - many thanks.
However, the OSA risk assessment has a specific risk category for services that have a Messaging (DM) service (1b).
Very few of our members use the DM facility, so its an easy decision to terminate it.
The OSA doesn't differentiate between public U2U services and private services (like ours). It seems a really simple idea to avoid that risk by disabling DM.

It seems ironic that OSA doesn't cover email communications between members.
 
It seems ironic that OSA doesn't cover email communications between members.
Presumably because that is off the site so that cannot cover it as there is nothing stored on the site database.

I'm sure what you want can be easily done by creating a custom user field nd then via a database query, if you start a new thread asking how to do that specifically I'm someone will be able to tell you how.
 
Thanks - how about this as the request in a new thread?

"How can I add a custom field that would appear in the User Profile: "E mail"?
And then how can I populate that field from the database so it contains the user's email address?
(Presumably that would need to be a CRON action to ensure that field remains up to date when a member changes their email address)?"
 
How can I add a custom field that would appear in the User Profile: "E mail"?
Creating the custom field is easy, you need to ask how to copy the email address into it.

When you create the custom user field you can make it editable so the users could update it themselves.

If it was me though I would just create the custom user field and send a bulk email to users asking them to do it themselves.

Also make the field available on registration
 
The OSA doesn't differentiate between public U2U services and private services (like ours)
If your forum is a closed community and you don't allow any random to sign up and register then might it not end up falling under the exemptions for things like internal company systems?

HOW can we add their email address to their profile automatically
The easiest way is to edit the member_about template.

Around about line 60 you'll see blocks of code like this:

HTML:
<xf:if is="$user.Profile.website">
    <dl class="pairs pairs--columns pairs--fixedSmall">
        <dt>{{ phrase('website') }}</dt>
        <dd>
            <a href="{$user.Profile.website}" rel="nofollow" target="_blank">{$user.Profile.website|url_display}</a>
        </dd>
    </dl>
</xf:if>

For each of the fields the about tab shows in a user's profile. You can add another one for email easily enough. I know you've mentioned you already have permission, but I would personally still be tempted to do one of the following:
  1. Provide a checkbox to opt in/out of displaying the email
  2. Provide a separate "displayed email" field which can optionally be completed and displayed
For the sake of a more complete answer let's assume we're going with (1) above. So go and create a new Custom user field (/admin.php?custom-user-fields/). Lets assume you call it displayemail, fill in the title, etc select preferences as a sensible location for the field, lets make it a Check boxes and then in the Options for choice fields section lets set the Value to 1 and the Text to: Display my email address on my profile page. Save that, you can always tinker with it again later.

So onto the template modification. Now if you have multiple styles that are independent of each other you'll need to do this to each style. If you just have the one style or their are inherited then modify that one or the parent. Locate the member_about template and slot this in adjacent to one of the other blocks of code that is displaying a filed (such as location or website, etc).

HTML:
<xf:comment>Display email addresses</xf:comment>
<xf:if is="$xf.visitor.user_id">
    <xf:if is="$xf.visitor.Profile.custom_fields.displayemail.1">                   
        <dl class="pairs pairs--columns pairs--fixedSmall">
            <dt>{{ phrase('email') }}</dt>
            <dd>
                {{ $user.email }}
            </dd>
        </dl>
    </xf:if>                       
</xf:if>

So what are we doing there? Well the first check <xf:if is="$xf.visitor.user_id"> is just to make absolutely sure we're only going to display this information to a logged in user, so we're making sure the visitor to the page has a user_id. We're then checking to ensure our user has opted into displaying their email for everyone to see: <xf:if is="$xf.visitor.Profile.custom_fields.displayemail.1">, so this is checking our custom field - displayemail and making sure the value was 1, which is what we set it to when checked. Then finally we get into actually displaying the field name (using a phrase) and the email itself: {{ $user.email }}, which you could of course opt to markup with a mailto anchor tag to make it clickable.

Another option since you mention you have permission to show the emails and your users are not likely to go and do lots of fiddling with settings is to provide them with an opt-out - which would at least give those that really don't want their email shown an option. Essentially much the same. Lets instead assume you called the custom field: dontdisplayemail and again set the Value to 1 and the Text to: Don't display to other members my email on my profile page. You'd then use a block like this in the member_about template:

HTML:
<xf:comment>Display email addresses</xf:comment>
<xf:if is="$xf.visitor.user_id">        
    <dl class="pairs pairs--columns pairs--fixedSmall">
        <dt>{{ phrase('email') }}</dt>
        <dd>
            <xf:if is="{$xf.visitor.Profile.custom_fields.dontdisplayemail.1}">
            {{ phrase('email_hidden') }}
            <xf:else/>
            {{ $user.email }}
            </xf:if>
        </dd>
    </dl>                    
</xf:if>

Then create a new phrase in XF: email_hidden with some suitable text to display when emails are hidden "Email not available" or whatever. So slightly different here in that I've opted to always show the field label, but only the value (the email) if they have not opted out. You could of course just not display the entire block.

Hope that's enough to get you going. Do remember to test and double check that your user's emails are not visible to the world at large after you've done any tinkering.
 
Thanks a lot, that's very helpful indeed.

We have a test site where I can test and refine..

Now that I know it could be done, I can go out to consultation so users have a chance to express an opinion.

Better than simply imposing!

Thanks and regards,
Mike
 
If your forum is a closed community and you don't allow any random to sign up and register then might it not end up falling under the exemptions for things like internal company systems?
That is a very good thought (y)🎉🍾

Looking through section 7 of the act, see below, I think there is a good chance we can fit into that exclusion, which would save a huge amount of trouble!


7(1)A user-to-user service or a search service is exempt if the conditions in sub-paragraph (2) are met in relation to the service.

(2)The conditions are—

(a)the user-to-user service or search service is an internal resource or tool for a business, or for more than one business carried on by the same person,

(b)the person carrying on the business (or businesses) (“P”) is the provider of the user-to-user service or search service, and

(c)the user-to-user service or search service is available only to a closed group of people comprising some or all of the following—

(i)where P is an individual or individuals, that individual or those individuals,

(ii)where P is an entity, officers of P,

(iii)persons who work for P (including as employees or volunteers) for the purposes of any activities of the business (or any of the businesses) in question, and

(iv)any other persons authorised by a person within sub-paragraph (i), (ii) or (iii) to use the service for the purposes of any activities of the business (or any of the businesses) in question (for example, a contractor, consultant or auditor, or in the case of an educational institution, pupils or students).

(3)In this paragraph—

  • “business” includes trade, profession, educational institution or other concern (whether or not carried on for profit);
  • “officer” includes a director, manager, partner, associate, secretary, governor, trustee or other similar officer
 
Back
Top Bottom