Skip to content

Instantly share code, notes, and snippets.

View actual-saurabh's full-sized avatar
💭
I may be slow to respond.

Saurabh Shukla actual-saurabh

💭
I may be slow to respond.
View GitHub Profile
@actual-saurabh
actual-saurabh / wc-hide-product-from-public-query.php
Created October 8, 2018 13:49
WooCommerce Hide Product from Public Query
<?php
// Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_action( 'pre_get_posts', 'llms_wc_remove_products_from_public_query' );
function llms_wc_remove_products_from_public_query( $query ) {
@actual-saurabh
actual-saurabh / llms-lesson-elementor-template-compatibility.php
Created October 12, 2018 03:47
Temporary Fix for Lesson compatibility with Elementor Templates
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
// only a temporary measure, remove once https://github.com/pojome/elementor/issues/5900 is resolved
add_filter( 'lifterlms_register_post_type_lesson' , 'llms_lesson_elementor_template_compatibility' );
function llms_lesson_elementor_template_compatibility( $lesson_post_type_params ) {
/*
* see https://github.com/gocodebox/lifterlms/blob/master/includes/class.llms.post-types.php#L223
@actual-saurabh
actual-saurabh / llms-order-users-table-by-membership.php
Created October 12, 2018 14:47
Order Users Table by LifterLMS Memberships (Draft)
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
/*
* This code is not perfect and returns more than one result for the same user.
* I'll take another stab at this to fix that.
* Also, this is not likely to work that well in case a user is enrolled in more than one membership.
*/
@actual-saurabh
actual-saurabh / course-name-in-lesson-body-class.php
Created October 19, 2018 18:21
Add Course Name in Lesson's body classes LifterLMS
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
function llms_course_name_in_body_class( $classes ) {
// bail early, if we're not on a lesson.
if( ! is_singular ( 'lesson' ) ){
return $classes;
}
@actual-saurabh
actual-saurabh / llms-custom-post_checkout-redirection.php
Created October 30, 2018 15:44
Redirect customers to custom urls in LifterLMS after checkout
<?php // Do not copy this line.
// Copy from under this line and paste into your child theme's functions.php.
// replace the default redirect_url.
add_filter( 'lifterlms_completed_transaction_redirect', 'llms_custom_checkout_post_checkout_redirection', 10, 2 );
function llms_custom_checkout_post_checkout_redirection( $original_redirect, $order ) {
// only proceed if the order has been for a particualr membership.
@actual-saurabh
actual-saurabh / llms-remove-fields.php
Created November 1, 2018 17:25
Remove field from registration and checkout screens
<?php // Do not copy this line.
// Copy from under this line and paste into your child theme's functions.php.
add_filter( 'lifterlms_get_person_fields', 'llms_remove_state_field', 10, 2);
function llms_remove_state_field( $fields , $screen ){
if( strcmp( $screen , 'checkout' ) == 0 ||
strcmp( $screen , 'registration' ) == 0) {
$fields = array_filter( $fields, 'llms_is_not_state_field' );
@actual-saurabh
actual-saurabh / llms-prerequisite-course-enrollment.php
Created December 5, 2018 04:14
Prerequisite Course Enrollment
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_action( 'llms_user_enrolled_in_course', 'llms_enroll_in_prerequisite_course', 10, 2 );
function llms_enroll_in_prerequisite_course( $student_id, $course_id ){
/*
* the prerequiste course's id.
@actual-saurabh
actual-saurabh / course-syllabus-collapsible-sections.css
Last active March 25, 2022 09:55
LifterLMS Collapsible Course Syllabus
.llms-syllabus-wrapper .llms-section-title {
cursor: pointer;
}
.llms-syllabus-wrapper .llms-section-title::after {
content: "\25b6";
float: left;
display: inline-block;
width: 15px;
text-align: left;
margin-right: 15px;
@actual-saurabh
actual-saurabh / llms-autocomplete-section-on-enrollment.php
Created March 14, 2019 15:29
Autocomplete a section on enrollment
<?php
add_action( 'llms_user_enrolled_in_course', 'llms_autocomplete_section', 10, 2 );
function llms_autocomplete_section( $student_id, $course_id ){
// only do this for a particular course.
if( (int) $course_id != 1051 ){
return;
}
@actual-saurabh
actual-saurabh / llms-sl-remove-stories.php
Last active March 26, 2019 16:45
LifterLMS Social Learning Remove Stories
<?php //don't copy-paste this line
// copy-paste from under here-->
// complete
remove_action( 'lifterlms_course_completed', array( 'LLMS_SL_Stories', 'complete' ), 25, 2 );
// earn achievement( badges, certificates, etc)
remove_action( 'llms_user_earned_achievement', array( 'LLMS_SL_Stories', 'achievement' ), 25, 3 );