moodle/moodle · error · moodle_exception

nopermissions

nopermissions

Error message

nopermissions

What it means

Moodle generic moodle_exception error key ('error' component) thrown in mod/forum/discuss.php when the user lacks the mod/forum:movediscussions capability (capabilitymanager->can_move_discussions($USER) is false) and the source forum is not of type 'single' (that case gets its own specific message). It is the standard permission-denied sentinel of Moodle, with get_capability_string('mod/forum:movediscussions') supplied as the debug detail; the fault is the user's role assignment in that module context.

Solutions

  1. Ask a manager to grant the mod/forum:movediscussions capability in the forum's context.
  2. Have a user with an appropriate role (e.g. teacher) perform the move.
  3. Override the capability at the course/module level if ordinary users should be allowed to move discussions.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at public/mod/forum/discuss.php:125 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of moodle/moodle@48ea8c3322 (2026-09-14). Data as JSON: /api/errors/53be9006037471e5. Report an issue: GitHub.

Appendix: source

Thrown at public/mod/forum/discuss.php:125

    $rsstitle .= ': ' . format_string($forum->get_name());
    rss_add_http_header($modcontext, 'mod_forum', $forumrecord, $rsstitle);
}

// Move discussion if requested.
if ($move > 0 && confirm_sesskey()) {
    $forumid = $forum->get_id();
    $discussionid = $discussion->get_id();
    $return = $discussionviewurl->out(false);

    if (!$forumto = $DB->get_record('forum', ['id' => $move])) {
        throw new \moodle_exception('cannotmovetonotexist', 'forum', $return);
    }

    if (!$capabilitymanager->can_move_discussions($USER)) {
        if ($forum->get_type() == 'single') {
            throw new \moodle_exception('cannotmovefromsingleforum', 'forum', $return);
        } else {
            throw new \moodle_exception('nopermissions', 'error', $return, get_capability_string('mod/forum:movediscussions'));
        }
    }

    if ($forumto->type == 'single') {
        throw new \moodle_exception('cannotmovetosingleforum', 'forum', $return);
    }

    // Get target forum cm and check it is visible to current user.
    $modinfo = get_fast_modinfo($course);
    $forums = $modinfo->get_instances_of('forum');
    if (!array_key_exists($forumto->id, $forums)) {
        throw new \moodle_exception('cannotmovetonotfound', 'forum', $return);
    }

    $cmto = $forums[$forumto->id];
    if (!$cmto->uservisible) {
        throw new \moodle_exception('cannotmovenotvisible', 'forum', $return);
    }

View on GitHub (pinned to 48ea8c3322)