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 / llms-certificate-title-merge-code.php
Last active May 25, 2018 13:51
Custom Merge Code for Certificate Title LifterLMS
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_filter( 'llms_certificate_merge_codes', 'llms_custom_certificate_title_merge_code', 10, 2 );
function llms_custom_certificate_title_merge_code( $merge_codes_array, $certificate_object ){
// add custom certificate title merge code to existing ones
$merge_codes_array['{certificate_title}'] = $certificate_object->title;
@actual-saurabh
actual-saurabh / llms-course-title-merge-code.php
Last active May 29, 2018 12:43
Custom Merge Code for Course Title
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_filter( 'llms_certificate_merge_codes', 'llms_custom_course_title_merge_code', 10, 2 );
function llms_custom_course_title_merge_code( $merge_codes_array, $certificate_object ){
// the triger post's (course's) id is in the lesson_id property of the $certificate_object
$course_title = get_the_title( $certificate_object->lesson_id );
@actual-saurabh
actual-saurabh / llms-login-shortcode-redirect-loggedin.php
Created May 29, 2018 13:45
Redirect Logged in Users on pages with [lifterlms_login] shortcode
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_action( 'template_redirect', 'llms_redirect_logged_in_on_login_shortcode' );
function llms_redirect_logged_in_on_login_shortcode(){
// don't do anything if a user is not logged in
if( ! is_user_logged_in() ){
@actual-saurabh
actual-saurabh / llms-welcome-course-enrollment.php
Last active April 17, 2019 06:40
Enroll all students into a welcome course when they enroll into any course in LifterLMS
<?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_welcome_course', 10, 2 );
// Uncomment to enroll when user joins a membership
add_action( 'llms_user_added_to_membership_level', 'llms_enroll_in_welcome_course', 10, 2 );
@actual-saurabh
actual-saurabh / llms-hide-checkout-fields-for-free-plan.php
Last active June 19, 2018 10:27
Hide Fields on Checkout Form for Free Access Plans
<?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_hide_fields_for_free_plans', 10, 2 );
function llms_hide_fields_for_free_plans( $fields, $screen ){
// bail if it isn't the checkout screen
if ( $screen != 'checkout' ){
@actual-saurabh
actual-saurabh / llms-welcome-course-to-membership-enrollment.php
Created June 29, 2018 12:33
Enroll into a membership on completion of a specific welcome course
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_action( 'lifterlms_course_completed', 'llms_enroll_in_restrictive_membership', 10, 2 );
function llms_completed_welcome_course( $student_id, $course_id ){
/*
* the welcome course's id.
@actual-saurabh
actual-saurabh / llms_membership_restricted_post_types.php
Last active June 29, 2018 12:50 — forked from thomasplevy/llms_membership_restricted_post_types.php
Extend membership restriction to courses, memberships and other post types
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_filter( 'llms_membership_restricted_post_types', 'my_membership_restriction_post_types' );
/**
* Add LifterLMS membership restrictions to a custom post type
* @param array $post_types array of custom post types
* @return array
@actual-saurabh
actual-saurabh / micro.json
Last active September 27, 2018 04:00
Simple Micro Example - Welcome Course for Members
{
"name": "llms/welcome-course-membership",
"title": "Welcome Course Membership",
"version": "1.0.0",
"description": "Automatically enroll new members of a membership into a welcome course.",
"homepage": "https://lifterlms.com",
"author": "saurabhshukla",
"tags": [ "onboarding", "membership", "course" ],
}
@actual-saurabh
actual-saurabh / class.llms.controller.login.php
Last active September 27, 2018 04:00
Complex Micro Example - Dummy Functionality
<?php
/**
* This can override the LifterLMS Class
* However, then we'll have to hook this one before loading LifterLMS itself
* This file can be included by LifterLMS by filtering the autoloader
* Include Override: lifterlms/includes/forms/controllers/class.llms.controller.login.php
*/
@actual-saurabh
actual-saurabh / schema-micro.json
Last active July 5, 2018 09:42
LLMS Micro Schema
{
"name": "package",
"version": "package",
"description": "package",
"homepage": "https://lifterlms.com",
"author": "lifterlms",
"tags": [ ],
"gist": "https://gist.github.com/actual-saurabh/3ce88c1b1465224eeab16e884d5916ec",
"title": "gist",