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 / class-llms-serial-number-generator.php
Last active April 7, 2022 09:50
Serial Numbers for Transaction Receipts
<?php // Do not copy this line
// copy from below this line
/**
* Generates sequential serial numbers for a given post type
*/
class LLMS_Serial_Number_Generator {
private $post_type = '';
@actual-saurabh
actual-saurabh / llms-access-plan-switch-filters.php
Created December 11, 2019 06:20
Access Plans Upgrade/Downgrade
<?php
// hide system access plans from pricing table and course/membership editor
add_filter( 'llms_get_product_access_plans_args', 'llms_custom_hide_system_access_plans_args' );
function llms_custom_hide_system_access_plans_args ( $args, $product, $free_only, $visible_only ) {
if( isset( $args['tax_query'] ) ) {
$args['tax_query'][0]['terms'][] = 'system';
<?php
/**
* Contains Navigation Action Class
*/
defined( 'ABSPATH' ) || exit;
/**
* Class for calculating navigation actions
*/
@actual-saurabh
actual-saurabh / llms-certificate-grade-merge-code.php
Created October 5, 2019 09:30
LifterLMS Certificate Merge Code for Grades
<?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_certificate_grade_merge_code', 10, 2 );
function llms_certificate_grade_merge_code( $merge_codes_array, $certificate_object ) {
// add custom certificate title merge code to existing ones. See https://github.com/gocodebox/lifterlms/blob/a1a6833c6e6bab57bf4356739463220e51f89408/includes/certificates/class.llms.certificate.user.php#L132
@actual-saurabh
actual-saurabh / restrospective-certificates.php
Created September 24, 2019 17:50
Award a Certificate associated with a trigger and an engagement to a user
<?php
/**
* Award a certificate engagement attached to a unit (course, quiz, etc) to a user
* @param int $user_id The ID of the user to award the certificate to.
* @param int $engagement_id The post ID of the engagement
* @param int $trigger_id The post ID of the trigger post (course, lesson, quiz, etc)
*/
function llms_award_certificate( $user_id, $engagement_id, $trigger_id ){
@actual-saurabh
actual-saurabh / llms-change-cols-number.php
Created July 1, 2019 16:51
Change LifterLMS registration field column class (llms-cols-6, etc)
<?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_change_form_cols', 10, 1 );
function llms_change_form_cols( $fields ) {
foreach ( $fields as $field ) {
if ( $field['id'] === 'llms_billing_city' ){
@actual-saurabh
actual-saurabh / llms-email-unit-redirection.php
Last active May 13, 2019 05:51
LifterLMS redirect users to login and back from email links of restricted content
<?php
/*
* Any links to restricted pages added to emails should contain a redirection parameter.
* When user lands on a restricted screen with a redirection parameter,
* they are redirected to the login screen (with the usual notice).
* On loggin in, the user is redirected back to the restricted page.
*/
add_action( 'lifterlms_content_restricted', 'llms_maybe_email_unit_redirect', 10, 1);
@actual-saurabh
actual-saurabh / llms-focus-mode.css
Last active May 13, 2019 07:20
LifterLMS Distraction Free Fullscreen mode
body.llms-is-focused .content-area {
background: #fff none;
padding:0;
overflow-y:scroll;
position:fixed;
width:100%;
height:100%;
top:0;
left:0;
bottom:0;
@actual-saurabh
actual-saurabh / llms-certificate-custom-merge-codes.php
Created April 2, 2019 15:47
LifterLMS Custom Merge Codes for Certificates
<?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_prefix_suffix_merge_codes', 10, 2 );
function llms_custom_certificate_title_merge_code( $merge_codes_array, $certificate_object ){
// add custom certificate title merge code to existing ones. See https://github.com/gocodebox/lifterlms/blob/a1a6833c6e6bab57bf4356739463220e51f89408/includes/certificates/class.llms.certificate.user.php#L132
$merge_codes_array['{merge-code-1}'] = get_user_meta( $certificate_object->user_id, 'custom_field_key_1', true );
@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 );