Cannot log a string with console.log?

I don’t see how this code isn’t doing what I expect. It seems to work over at w3schools.


<script type="text/discourse-plugin" version="0.8">

  const user = api.getCurrentUser();
  const { setDefaultHomepage } = require('discourse/lib/utilities');

  console.log("Primary group: " + user.primary_group_name);
  console.log('full map: ' + settings.group_homepage_map);
  if (settings.group_homepage_map && settings.group_homepage_map_enabled) {
      const map = settings.group_homepage_map.split("|");
      var two = map[1];
      console.log("Hello world!");
      console.log("hello? " + map);
      console.log("my map zero: " + map[0]);
      console.log(String('some text'));
      console.log("wwf: " + map[0]);
      console.log('two' + map[1] + 'one');
      console.log("first group: " + map[0].split(',')[0]);
      console.log("first url: " + map[0].split(',')[1]);
      console.log("second: " + map[1]);
      console.log("thing: ", map[0].split(",")[1]);
  if (settings.home_url_override && settings.home_url_override_group.length == 0 ) {


All that’s showing up in the javascript console is this:

Primary group: lastone
full map: lastone,c/transcription/5|testergroup,latest
hello? lastone,c/transcription/5,testergroup,latest
my map zero: lastone,c/transcription/5
wwf: lastone,c/transcription/5
first group: lastone

So it appears that I cannot log just a string, and I can’t access item [1] of an array.

The gods must be crazy.

Did you mean to split by |? Why not ,?

It’s a map of a group to their desired home page.

     description: "group,c/cat/5|group2,c/cat2/6"

So I’m splitting on | to get each pair and then split those on the , to get

  • group -> c/cat/5
  • group2 -> c/cat2/6

But that doesn’t explain why console.log("Hello world!"); isn’t producing text. . .

1 Like

That would tell me the code isn’t getting executed. Does a console.log fire if you’re outside the if statement?

1 Like

Thanks, Justin! I’ll give it a shot, but many of the logs in that same block are getting called. And logging a setting) string doesn’t die but a string plus a string on a variable does fire.