目前我正在使用moodle创建一个网站。 我想创建一个功能,如果用户未登录,他们将重定向到登录页面。 我怎样才能在Moodle中做到这一点?
最佳答案
假设 - 用 PhP 编写自定义页面,托管在 Moodle 网站的同一服务器上。
然后页面就可以访问 session 信息,任务非常简单。
首先调用moodle bootstap,然后调用moodle函数来检查是否有效登录。
require_once('../../config.php'); // specify path to moodle /config.php file
// require valid moodle login. Will redirect to login page if not logged in.
require_login();
// if you also include the id number of a course then require permisision to view a particular course
require_login(78); // requires login and permission to view course id 78.
关于authentication - 如何检查用户是否登录moodle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4083878/