let D3js code knows current user name

I’m working with wordpress and my data content with D3js are user dependent.
Each user has a dedicated data directory and I would be able to choose the right one on the fly.
I known the current user_login in PHP but I don’t know how to let D3js aware of that?

Related posts

1 comment

  1. If you have the variable in PHP you can simply pass it to Javascript like this.

    <body>
        <script>
          var js_var = "<?php echo $userId; ?>";
            alert(js_var);
        </script>
    </body>
    

    Then you can use it in d3 in anyway you like.

Comments are closed.