LMSouq
moodle-core Open

Check User's login in moodle

WO
woj_jas
1 month ago
3 views
Problem Description
I'm writing custom.php file to my moodle and i have question. 1. How to check if user is logged in and how to check his login ? 2.How to make my page avaliable only for logged students ? Some Code i already wrote: // The number of lines in front of config file determine the // hierarchy of files. require_once(dirname(dirname(__FILE__)).'/../../config.php'); $PAGE->set_context(get_system_context()); $PAGE->set_pagelayout('admin'); $PAGE->set_title("Badanie Umiejętności - eszkolenia24.pl"); $PAGE->set_heading("Blank page"); $PAGE->set_url($CFG->wwwroot.'/blank_page.php'); echo $OUTPUT->header(); ?> <h1>Some Text</h1> <div class="row"> <div class="col-lg-12 col-md-12 col-xs-12 col-sm-12"> </div> <?php echo $OUTPUT->footer(); ?> Answer 1: require_login();

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base