Fixing the LearnDash "Access to certificate page is disallowed" Error

|

If you try to use the Divi Builder (backend visual builder) to edit a LearnDash certificate, you may encounter the following error: "Access to certificate page is disallowed". This error is due to an incompatibility between the way Divi Builder and LearnDash work, rather than an error in either one of them. Here's how to fix it:

Fixing the Certificate Access Error Using Divi LearnDash Kit

A fix for this issue is included in Divi LearnDash Kit. Simply install and activate Divi LearnDash Kit and the fix will automatically be applied. It is available in version 1.2.4 upwards.

Fixing the Certificate Access Error Using PHP

If you're comfortable adding PHP to your site, here's the same code used by Divi LearnDash Kit to fix the issue. Simply add it, for example, into the functions.php file of your child theme and it should take effect when you next load the certificate edit page.

// === Fix certificate editing blocked in BFB ===
// - Error in BFB: "Access to certificate page is disallowed."
add_action('template_redirect', 'dbc_allowCertificateEditingInBfb', 4);

if (!function_exists('dbc_allowCertificateEditingInBfb')) {
	function dbc_allowCertificateEditingInBfb() {
		$bfbPage = isset($_GET['et_bfb']);
		$userCanEdit = (is_user_logged_in() && function_exists('et_pb_is_allowed') && et_pb_is_allowed('edit_posts'));
		if ($bfbPage && $userCanEdit) {
			// LD pre-3.2.3
			if (isset(SFWD_CPT_Instance::$instances['sfwd-quiz'])) { // Quiz CPT instance is doing the certificate access check
				remove_action('template_redirect', array(SFWD_CPT_Instance::$instances['sfwd-quiz'], 'template_redirect_access'));
			}
			// LD 3.2.3 and up
			remove_action('template_redirect', 'learndash_certificate_display', 5);
		}
	}
}

This post may contain referral links which may earn a commission for this site

Hundreds of new features for Divi
in one easy-to-use plugin

4 Comments

  1. Wen trying to fix with the php function : "Cannot redeclare dbldk_allowCertificateEditingInBfb() (previously declared in wp-content/plugins/divi-learndash-kit/features/fix-bfb-certificate-access/fix-bfb-certificate-access.php:7)
    "

    Reply
    • This will have occurred because the same code was being applied both manually (using the PHP fix) and by Divi LearnDash Kit, causing the function to be redeclared. I've added a check to the code so the error shouldn't happen in the future. Note that this means the plugin's version of the code will be the one that runs, if present. Thanks!

      Reply
  2. I am sorry but the Divi LearnDash Kit 1.2.6 doesn't fix this error for me.. I don't know what I am doing wrong.

    Reply
    • Hi Delphine, it looks like the recent LearnDash update made some changes which stopped the fix from working. I've just updated the post above with a revised fix that should work with both the current and older LearnDash versions. This will be in the next update of Divi LearnDash Kit (v1.2.8). I hope it helps!

      Reply

Submit a Comment

Your email address will not be published. Required fields are marked *