National Flags - Display user nationality in Discourse

Have you enabled it in /admin/site_settings/category/plugins?filter=nationalflag?

1 Like

That would have been a nice solution, but yes, it’s enabled.

Edit: Whooops. Now the National Flag option has magically appeared. Maybe this was a caching thing…

@tophee, you said in the other thread that you’d disabled it
EDIT: glad its working now.

@JagWaugh I updated the plugin last night to hopefully fix the warning messages once and for all. It’s been running on my forum since then and (so far) no warnings.

Just updating the live site now…

Still getting:

Uncaught exception: TypeError: Cannot convert ‘e.attrs.userCustomFields’ to object

Uncaught TypeError: Cannot read property ‘nationalflag_iso’ of null

TypeError: e.attrs.userCustomFields is null

I take it that none of these are browser cache issues?

Since this topic is now the main place to discuss the plugin, I want to just mention a feature request I made elsewhere:

To put it more technically, can we let users choose a secondary National Flag right below the present flag setting? The scondary flag would be displayed next to the first one.

Andrew, where are you seeing these exactly? Local Browser console or site/logs? I haven’t seen anything like these since the update last night. (admittedly, my own forum is low traffic)

They are in /site/logs. Only 8 users online atm, 5 or so of them were online before and while I ran the last update (hence the cache question).

2 more “e.attrs.userCustomFields is null”. Judging by the timestamps these seem to be happening when a user replies to a post via the web interface. (i.e. they aren’t being triggered by someone just looking at posts.)

I’m not sure if that is much help to you.

It’s a big help, thanks.
I thought I’d fixed this. In the decorator, I check to see if that value is not null before carrying on with adding the flag (when a new post is made). Obviously missed something though. if it’s causing problems, I’d recommend just disabling the plugin until it’s completely fixed. I’ll try and have a look again over the weekend.

1 Like

And risk a user revolt, are you mad???

I’m ok to keep running with it if it helps you narrow in on what is causing the error messages. Our forum is fairly active, with a relatively number of users using both the web and the email interface. I haven’t actually announced the nationalflags yet, so only a few have figured it out on their own, or asked.

Some more data points since the update this morning:

I’ve had one user with no flag defined create a new topic via the web interface, and this did not generate a “nationalflags” error in /logs

Replies via email, from users with no flag defined do not generate the error.

Not every reply or new topic from a user with no flag defined seems to raise the error.

hth.

1 Like

I also have an error for you:

TypeError: Cannot read property 'nationalflag_iso' of null
	at https://forum.example.net/assets/plugin-third-party-015118efc2c13c2c90bcfcc6beece348477a2141a2a4ebcfc245d5cd96a19deb.js:2:28629
	at https://forum.example.net/assets/application-e8be41068653f348d6bb73e96add1db5ffb5938f989f70ef4bc22a3beb3a16ec.js:45:15286
	at Array.map (native)
	at https://forum.example.net/assets/application-e8be41068653f348d6bb73e96add1db5ffb5938f989f70ef4bc22a3beb3a16ec.js:45:15263
	at d (https://forum.example.net/assets/application-e8be41068653f348d6bb73e96add1db5ffb5938f989f70ef4bc22a3beb3a16ec.js:45:15294)
	at t.m [as draw] (https://forum.example.net/assets/application-e8be41068653f348d6bb73e96add1db5ffb5938f989f70ef4bc22a3beb3a16ec.js:45:16123)
	at t.value (https://forum.example.net/assets/application-e8be41068653f348d6bb73e96add1db5ffb5938f989f70ef4bc22a3beb3a16ec.js:45:18782)
	at r (https://forum.example.net/assets/vendor-52ed1f7ea87a692ca7ec8f3b75bb76997f730cae151edfe8f467849ef9ddde78.js:7:14880)
	at i (https://forum.example.net/assets/vendor-52ed1f7ea87a692ca7ec8f3b75bb76997f730cae151edfe8f467849ef9ddde78.js:7:14810)
	at i (https://forum.example.net/assets/vendor-52ed1f7ea87a692ca7ec8f3b75bb76997f730cae151edfe8f467849ef9ddde78.js:7:8247)

And you can read about some very weird behaviour that is possibly also related to the plugin here.[quote=“tophee, post:5, topic:58266”]
I am using different browsers to login with as different users for testing purposes but before that error happened, I accidentally used a new tab in the same browser (Chrome) to login with a different account. When I went back to the tab with the original Chrome user, everything looked fine because I didn’t refresh the page and so I posted a reply. I was surprised to see that the reply I had just typed had the other users avatar. That’s how I realized that I had logged the other user in with Chrome rather than Firefox. So it made sense. But what didn’t make sense was that the Firefox user all of a sudden had the chrome user’s national flag next to it even though I had not touched that setting for that user.
[/quote]

3h and 22 new posts since I updated to 59ab187… nationalflags would appear to no longer be causing error messages in /logs. Thanks @Ebs

1 Like

@Ebs I also want this to show in registration form.

Works great!

I’d love to see a tooltip, however – sometimes people may not recognize certain flags. Give them an “ah” moment by hovering over the flag to reveal what country (or the ISO code, at least)

5 Likes

Hi, I’m trying to get this plugin to run, but unfortunately I fail. I’m currently using a development version so I just copy the plugin to the plugin folder. Unfortunately, the user settings to choose a flag do not appear in Preferences -> Interface as they should according to the provided screenshot.

The plugin is activated in the Admin settings and deactivating and activating again does not help. There is also the option “nationalflag iso” in the settings, which I left at “none” as I have no idea what the option is for. Do I need to set it somehow? And how? Or does someone have an idea what could be wrong?

Thanks a lot!

Does it work if you install it the proper way via app.yml?

Unfortunately there is no app.yml in the development version. But when I tried it on another machine in the regular docker version it didn’t work either.

Also, it does appear in Discourse, as I do have the admin settings available. However, it’s not visible to any user that is not admin.

Edit: I discovered that I did not have Sidekiq running and now it’s not really working as it has around half a million jobs after importing the old forum. Could this be a reason for the plugin not working?

I set up a fresh productive discourse today. It’s version v1.8.0.beta12 +40 and up to date right now. Beside the e-mail settings I only added this plugin. The problem remains the same, i.e., it appears in the admin area, but not in the user settings.

No idea what’s going wrong. Try another plugin, see if that works? Have a look at your logs, see if the plugin is being loaded at startup. Add some console.logs to the Javascript. Its hard to guess what the problem is without more information.