<?php global $current_user;
get_currentuserinfo();
$user_name = $current_user->user_login;
$user_ID = get_current_user_id();
?>
<script type="text/javascript">
var username = <?php echo json_encode($user_name) ?> ;
var userID = <?php echo json_encode($user_ID) ?> ;
</script>
<script>
document.domain = “10.0.100.99″;
var username = parent.username;
var userID = parent.userID;
document.write(‘Your username is ‘+username+’ and user id is ‘+userID+’.’);
</script>
And load it with the following on the wordpress page:
<script type="text/javascript">
document.domain = "10.0.100.99";
</script>
<iframe id="example1" style="border: none; width: 100%; height: 500px;" src="http://10.0.100.99:3838/shiny.tests/App-7/test.html" width="300" height="150" frameborder="0"></iframe>
Note that document.domain is needed both in the wordpress page and the iframe because they are on different domains (different ports are apparently enough).
What does not work:
I tried to hack together the code based on the guide here: http://www.r-bloggers.com/sending-data-from-client-to-server-and-back-using-shiny/
ui.R: http://pastebin.com/j3uMNPmb
server.R: http://pastebin.com/UkBY8YMF
java: http://pastebin.com/e6z1Bxht
2 problems:
1) as soon as I add the 3 lines of code to the javascript I need to the copy/pasted example shiny doesn't load anything. I just get a blank page. Even if I don't use the variables in the next piece of code.
2) Even if it worked this would still require a click on the div block to get any data. I need it to pass the variable userID on startup. Is there a way to do this?
Any hints are highly appreciated.