Apply Countries to my site

Permalink Browser Info Environment
Hi John,

When Members sign up for my site there is a text field for them to enter their country. I should think about 750 members have filled it in out of about 1500 members but because it is a text field it is completed inconsistently.

I find now that many of the questions asked on the site require us to know the country the person is in. Here are the things I would like to achieve and I wonder whether this addon can help me to do it:

- Enforce choice of country during signup
- Allow me to edit the member's country, so that I can manually migrate existing members, so that they don't have to do it (or can I make them do it the next time they log in?)
- display the member's country and flag on their profile and in my forums (core team discussion addon)

Many thanks (and thanks for your help with everything else! I'll leave some reviews very soon)
Mike

Type: Pre-Sale
Status: In Progress
designserve
View Replies:
JohntheFish replied on at Permalink Reply
JohntheFish
This addon helps you manage the core countries list and states list, as used in the core address attribute type. It can't really do anything to directly solve your problem.

You could make the country field compulsory on your form. If not too late, you could make it an address so the country becomes a select rather than free text.

You could look at IP Geo location, as provided by http://www.concrete5.org/marketplace/addons/maxmind-ip-geoloc/... . It also includes some MD symbols for geo location.

To show a visitors country name
IP_ADDRESS MAXMIND_COUNTRY


Then my Flags addon http://www.concrete5.org/marketplace/addons/flags/documentation/... has MD symbols to insert a flag.

To show a visitors flag at 32 pixels
IP_ADDRESS MAXMIND_COUNTRY_CODE FLAG 32
JohntheFish replied on at Permalink Reply
JohntheFish
If you added Black Magic Data to the solution, you could use it to set the country attribute

For example
USER END_ON_NULL
IP_ADDRESS MAXMIND_COUNTRY 
END_ON_NULL 
SET_​CURRENT_​USER_​ATTRIBUTE "your country attributes name"


The first END_ON_NULL will quit the MD if there is no logged in user.
The second END_ON_NULL will quit the MD if there is no country found.

In practice you would probably also want to insert a test to see if the attribute was already set before setting it. That would save on unnecessary database updates.
designserve replied on at Permalink Reply
designserve
Thanks John, I'll do some digging into that. Mike
designserve replied on at Permalink Reply
designserve
Hi John,

I'm looking to implement this now (after all this time!). I've got Country State Manager and Flags and I'll get the MaxMind addon if you think I need it. Looks good.

My users have been signing up completing the mandatory COUNTRY attribute that I created, so they have been filling it in with various combinations of text!

So, I was thinking to implement what you suggested and to ask you to help me to understand how to check whether the attribute is set or not. However, in most cases it is already set. And it will be set incorrectly in the majority of cases.

I don't know whether to create a brand new attribute and try to implement what you suggested above. If so, I don't know where to implement it. I think I would want the user to be able to edit it though, if they want, and not be forced to use what Maxmind geo ip suggests. for example, I suppose that mine would set to UK and then I would want to change it to Wales.

Just so that you know what I'm trying to do... I want to display a user's country and flag on their profile, so that other Members can see where they are from. And I want to display their country and flag against their forum posts. Those are my main objectives.

I don't want to force users to fill in their full address when they register though. That would force them to enter unnecessary data and be offputting.

It is important for users to see which country their correspondent is in because they ask each other questions such as what power cables are suitable for different models of keyboards. Hard to answer if we don't know the country, therefore we repeat over and over "What country are you in?". I'm mainly looking to simplify those things.

Your addon also helps with ecommerce of course so that's great as I've recently added it to the site.

Many thanks,
Mike
JohntheFish replied on at Permalink Reply
JohntheFish
This is un-tested, but I would do something like:
# no user, so quit
USER END_ON_NULL
# attribute already set, so quit
ATTRIBUTE "your country attributes name"
NOT END_ON_NULL
# look up country, quit if not found
IP_ADDRESS MAXMIND_COUNTRY 
END_ON_NULL
# finally, set the country from the IP lookup
SET_​CURRENT_​USER_​ATTRIBUTE "your country attributes name"


The attribute would be a user attribute and you could make it editable from the user profile.

If this is in a displayable block, you could it to use ZERO_AS_NBSP_THEN_END, so you don't get an unfilled MD expression.

In practice, I would put the above in an MD direct block and add the block to the login page or home page. It only needs to execute once per user because once the attribute has been set, it will not write over it. That allows the user to edit it in their profile if it has been set incorrectly.

I may have an MD powered select attribute coming soon that would be ideal for country selection. I have a customer project that may require it, so if it turns out to be needed for the project I will be adding it to the MD family somewhere.
designserve replied on at Permalink Reply
designserve
John,

Thank you very much for the response. I'm going to experiment with that over the next couple of evenings. I'm going to try it out with a brand new attribute.

I'm wondering whether it is it possible for the attribute to be editable by the user in that it would be a dropdown list linked to country state manager. I'll look out for your response but am going to look into that now.

If you get around to implementing the MD powered select attribute please do let me know.

Many thanks,
Mike
JohntheFish replied on at Permalink Reply
JohntheFish
At the moment, you would need to write a custom attribute to do that.
designserve replied on at Permalink Reply
designserve
Thanks John,

I'm going to follow through this tutorial and try to do that:

http://legacy-documentation.concrete5.org/tutorials/create-a-custom...

Best wishes,
Mike
designserve replied on at Permalink Reply
designserve
Hi John,

The custom attribute is beyond me until I have more time spare to work it out.

I have it working using the following code:

# no user, so quit
USER END_ON_NULL
# attribute already set, so quit
ATTRIBUTE "membercountry"
NOT  ZERO_AS_NBSP_THEN_END
# look up country, quit if not found
IP_ADDRESS MAXMIND_COUNTRY 
END_ON_NULL
# finally, set the country from the IP lookup
SET_CURRENT_USER_ATTRIBUTE "membercountry"


I've then been trying to display the user's flag but I don't think that's possible with the current symbols is it? Because the maxmind symbol requires the ISO code rather than the full country name?

Cheers,
Mike
designserve replied on at Permalink Reply 1 Attachment
designserve
Hi John,

Would you mind helping me to refine what I'm doing and help solve a riddle?

I'm setting a user attribute for country as follows:

# no user, so quit
USER END_ON_NULL
# attribute already set, so quit
ATTRIBUTE "membercountry"
NOT ZERO_AS_NBSP_THEN_END
# look up country, quit if not found
IP_ADDRESS MAXMIND_COUNTRY 
END_ON_NULL
# finally, set the country from the IP lookup
SET_CURRENT_USER_ATTRIBUTE "membercountry"


This Country name will be displayed on the user's profile etc.

Next, I set another attribute - countrycode

# no user, so quit
USER END_ON_NULL
# attribute already set, so quit
ATTRIBUTE "membercountrycode"
NOT ZERO_AS_NBSP_THEN_END
# look up country, quit if not found
IP_ADDRESS MAXMIND_COUNTRY_CODE 
END_ON_NULL
# finally, set the country from the IP lookup
SET_CURRENT_USER_ATTRIBUTE "membercountrycode"
FLAG 64


This saves the user's country code. FLAG 64 is just there for testing.

Next I save an attribute called 'memberflag'

USER END_ON_NULL
ATTRIBUTE "memberflag"
NOT ZERO_AS_NBSP_THEN_END
ATTRIBUTE "membercountrycode"
FLAG 64
SET_CURRENT_USER_ATTRIBUTE "memberflag"


All of the above are working fine.

This should enable me to display the user's flag on their profile. However, when I display the attribute on the profile I just get the css code displaying as you can see on my profile (see attachment)

Any tips on how to show the actual flag? I've enabled the css on all pages in the dashboard.

Many thanks,
Mike
JohntheFish replied on at Permalink Reply
JohntheFish
It looks like the output from MD is being escaped by the page showing it.

Is it in a content or cache free content block? If so, you could use the HTML equivalent.

If not, then it could be the php in the profile single page that is escaping the attribute value. That could be deliberate coding, as any user editable attribute may open a route to a security attack by injection. So be careful about just what you override there.

You may also need to check the flags css is being loaded, as per the dashboard options onhttps://www.concrete5.org/marketplace/addons/flags/documentation/...
designserve replied on at Permalink Reply 1 Attachment
designserve
I guess the profile page is escaping it.

See the attachment, the following code pulls the flag correctly.

PAGE OWNER END_ON_NULL
ATTRIBUTE 'memberflag'


I guess I'll have to put the flag at the top of the page unfortunately. I don't want to mess with the profile page code for now.

If I was viewing someone else's profile, what MD symbol coudl I use so that it retreives their 'memberflag' attribute?

Many thanks,
Mike
JohntheFish replied on at Permalink Reply
JohntheFish
You can use the PROFILE symbol to get the user associated with a profile page.
designserve replied on at Permalink Reply
designserve
Thanks! As always you're a star!
designserve replied on at Permalink Reply
designserve
Hi John,

This was all working beautifully until a couple of days ago. What I'm getting now is that the maxmind addon picks up my IP address etc correctly but the magic data expressions are returning the IP address (and country etc) of the server (which is in Germany). Any ideas?

Cheers,
Mike
JohntheFish replied on at Permalink Reply
JohntheFish
Internally it uses the servicehttp://l2.io/ip

I am re-building my dev system at the moment, so won't be able to look into this for a couple of days. As you note, I suspect thee could be a confusion between browser and server IP addresses. I will investigate further when I have my dev system up and running again.
designserve replied on at Permalink Reply
designserve
Thank you John
JohntheFish replied on at Permalink Reply
JohntheFish
I inadvertently introduced a glitch in the update last week. new version 2.7.15 should fix the problem.
v2.7.15
Fix issue where IP_ADDRESS could return the server address. Added new symbol SERVER_IP_ADDRESS
designserve replied on at Permalink Reply
designserve
Thanks John that seems to be working perfectly again!

Cheers,
Mike

concrete5 Environment Information

# concrete5 Version
5.6.3.3

# concrete5 Packages
Add Multiple Pages (2.1.1), Advanced Page List (1.0.3), Backup Voodoo (2.3.5.1), Blocks by AJAX (2.3.0.5), Bootstrap (3.1.1.4), Discussion (1.8.6), Easy Tables (2.0.1), File List Pro (1.2.3), File With Description (1.1), Front End Filemanager (1.1), Front End File Uploader (2.2.2), HTML5 Audio Player Basic (1.1.6), Iframe (1.0), Instant CSS (1.1), Login (1.1.1), Magic Data (2.9.8), Magic Data Symbols1 (2.7.6), Magic Heading (1.3), Magic Tipple (1.6), Mailing List (2.54), Multiple Domains (1.4.7), Multiple Domains Debug (0.1), Next & Previous (1.02), Paypal Cart System Pro (1.1), Paypal Donations Box (1.0.1), Popup Login (1.0.5), Pro Blog (12.4.4), Rigid Light - Theme (2.1), Sapphire (1.5.0), Simply Clean - Theme (2.1), Sisimizi's Download Folder (1.0), Site Notifications (1.0.1), Slate Theme (1.5.3.1), Sortable Fancybox Gallery (1.17), tnSpacer (1.3), Toolbar Quick Links (1.2.0.1), Uber List (1.8.1), Universal Content Puller (1.4.3), Universal Content Puller Sources1 (1.4), ViewPort (1.0), Whitespace Theme (1.2).

# concrete5 Overrides
blocks/content, blocks/discussion_guestbook, blocks/discussion_post_list, blocks/login, blocks/multiple_domains_autonav, blocks/next_previous, blocks/problog_list, blocks/user_badges, elements/tracking.php, helpers/navigation.php, helpers/spellchecker.php, css/discussion.css, css/discussion.css.gz, libraries/page_cache, libraries/request.php, single_pages/login.php, single_pages/page_not_found.php, single_pages/register.php, themes/slate_custom, themes/slate_multiple, themes/slate_technics, themes/viewport_custom, themes/whitespace_custom, themes/slate_custom_black, themes/slate_KN7000

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - Off
Full Page Caching - On - If blocks on the particular page allow it.
Full Page Cache Lifetime - Only when manually removed or the cache is cleared.

# Server Software
Apache

# Server API
cgi-fcgi

# PHP Version
5.4.38

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dba, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imap, intl, ionCube Loader, json, libxml, mbstring, mcrypt, mysql, mysqli, mysqlnd, openssl, pcre, PDO, pdo_mysql, pdo_sqlite, Phar, posix, Reflection, session, shmop, SimpleXML, soap, SPL, SQLite, sqlite3, standard, tidy, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, zlib.

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 20
max_input_nesting_level - 64
max_input_time - -1
max_input_vars - 1000
memory_limit - 128M
post_max_size - 8M
sql.safe_mode - Off
upload_max_filesize - 2M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5

Browser User-Agent String

Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.