Skip to content

Instantly share code, notes, and snippets.

@thomasplevy
Last active October 4, 2016 00:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasplevy/8f9936546e81c3ac9c2f8ac360fc58af to your computer and use it in GitHub Desktop.
Save thomasplevy/8f9936546e81c3ac9c2f8ac360fc58af to your computer and use it in GitHub Desktop.
"Fix" LifterLMS No Access Template when Divi is the theme
<?php // don't include this if pasting into a php file
/**
* Add Divi Related HTML to LifterLMS templates that need some extra elements
*
* Tested up to Divi v3.0.9
*/
/**
* Remove default LifterLMS Content Wrappers
*/
remove_action( 'lifterlms_before_main_content', 'lifterlms_output_content_wrapper', 10 );
remove_action( 'lifterlms_after_main_content', 'lifterlms_output_content_wrapper_end', 10 );
/**
* Before Content
* @return void
*/
function my_llms_before_content() {
echo '
<div id="main-content">
<div class="container">
<div id="content-area" class="clearfix">
<div id="left-area">
';
}
add_action( 'lifterlms_before_main_content', 'my_llms_before_content' );
/**
* After content
* @return void
*/
function my_llms_after_content() {
echo '
</div> <!-- #left-area -->
';
get_sidebar();
echo '
</div> <!-- #content-area -->
</div> <!-- .container -->
</div> <!-- #main-content -->
';
}
add_action( 'lifterlms_after_main_content', 'my_llms_after_content' );
@appinlet
Copy link

appinlet commented Jul 13, 2016

This didn't work on my website, as I hide the sidebar by default and then add it manually to the related Divi Page in the Divi Editor. I created a "lifterlms" folder in the root of my Child theme, and then I created a file named "content-no-access.php". I've included my code below:

<?php
/**
 * The Template for displaying all single courses.
 *
 * @author      codeBOX
 * @package     lifterLMS/Templates
 *
 */

if ( ! defined( 'ABSPATH' ) ) { exit; }
global $post;
do_action( 'lifterlms_before_main_content' );
?>
<div id="main-content">
    <div class="container">
        <div id="content-area" class="clearfix">
            <div id="left-area">
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>


                    <div class="llms-summary entry-content">
                    <?php llms_print_notices(); ?>

                        <?php
                            do_action( 'before_lifterlms_no_access_main_content' );

                            do_action( 'lifterlms_no_access_main_content' );

                            do_action( 'after_lifterlms_no_access_main_content' );
                        ?>

                    </div>

                </div>
            </div> <!-- #left-area -->
            <?php get_sidebar(); ?>
        </div> <!-- #content-area -->
    </div> <!-- .container -->
</div> <!-- #main-content -->
<?php do_action( 'lifterlms_after_main_content' ); ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment