can’t access dashboard and showing forbidden page

Here is the short sweet answer.

Somewhere you, a plugin, or your theme are doing something like this:

wp_register_script( 'myscript', get_template_directory_uri() . '/path/to/myscript.js', '', '', true );

What should be happening is this:

add_action(
  'wp_enqueue_scripts',
  function() {
    wp_register_script( 'myscript', get_template_directory_uri() . '/path/to/myscript.js', '', '', true );
  }
);

From the Notice:

Scripts and styles should not be registered or enqueued until the
wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts
hooks

In other words, somewhere scripts are being registered prematurely. By hooking to one of the hooks listed in the Notice, or any hook after those run, you ensure that the scripts are registered when they should be and not before.