by dewey decibel.
seriously this is my first and LAST post on moodle forums, this is the worst forum software i have even encountered.
I have a solution but it relies on CORS.
please read this page about how to setup CORS on your server:
then add this code to your functions.php in wordpress theme folder. Keep in mind you have to change it slightly to have your url instead.
seriously this is my first and LAST post on moodle forums, this is the worst forum software i have even encountered.
For some reason i can't post code here to look good, and i got flagged as a spammer when i tried to post the pastie link so here it is, you have to fix the url slightly as you would expect it to be formatted normally.
http pastie org/9344952
function moodle_sso ()
{ ?>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
function crossDomainPost(user, pass) {
$.ajax({
type: 'POST',
cache: false,
xhrFields: {
withCredentials: true
},
crossDomain: true,
data: {"username":user, "password":pass},
success: function(responseData, textStatus, jqXHR) {
$('#loginform').submit();
// console.log(textStatus+' with POST')
},
error: function (responseData, textStatus, errorThrown) {
// eeeek! failed to login to moodle, this is bad.
}
});
}
$(document).ready(function(){
$('#wp-submit').click(function(ev){
ev.preventDefault();
return crossDomainPost($('#user_login').val(), $('#user_pass').val());
})
})
</script>
<?php
}
add_action('login_footer', 'moodle_sso');