[ad_1]
Hi,
We are so sorry, we don’t have that feature but by default, the user can’t view the content of the course if it not free and they still not enroll.
Thanks
I found solution for that. Find js.php and add the codes below.
Path of js.php file:
wp-content > plugins > learnpress > templates > content-quiz > js.php
Find if ($total_question) : line in js.php and make the changes.
if ($total_question) :
?>
if ($total_question) :
?>
<?php
if(is_user_logged_in()){
?>
<div id="learn-press-quiz-app"></div>
<script>
document.addEventListener('DOMContentLoaded', () => {
if (typeof LP !== 'undefined') {
LP.Hook.addAction('course-ready', () => {
LP.quiz.init(
'#learn-press-quiz-app',
<?php echo json_encode($js); ?>
)
});
}
});
</script>
<?php
}
else echo "<div class="alert alert-info">You must login to start the quiz !</div>";
else :
esc_html_e('You haven\'t any question!', 'learnpress');
?>
<?php endif; ?>That’s all. Magic part is the wordpress built-in function is_user_logged_in().
We can detect if the user logged in or not. So it helps us to restrict the content.
