Skip to content

Instantly share code, notes, and snippets.

View thomasplevy's full-sized avatar
🍗
I'm Hungry

Thomas Patrick Levy thomasplevy

🍗
I'm Hungry
  • Moose Town Media Business Company
  • Phoenix, AZ
  • 15:18 (UTC -07:00)
View GitHub Profile
<?php
$certs = LLMS()->certificates(); // our certs class
$cert_id = 123; // this should be the WP Post ID of the certificate you created on the admin panel via LLMS
$related_post_id = 456; // this is really for record keeping only at the moment
// should be the WP post id of the course, lesson, or section which
// the student has completed to earn the certificate
$students = new WP_User_Query(); // get your students however you see fit
if ( ! empty( $students->results ) ) {
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
/**
* Engagments Class
*
* Finds and triggers the appropriate engagement
*/
class LLMS_Engagements {
<?php
add_action( 'init', 'my_manual_achievement' );
function my_manual_achievement() {
$user_id = 123; // WP User ID of the user you want to award an achievement to
$achievement_id = 456; // WP Post ID of the LifterLMS Achievement Post you want to award to the user
$post_id = 5202; // The Releated WP Post ID that triggered the awarding of this achievement. This could be a Course, Lesson, Section, or Quiz ID
$achievements = LLMS()->achievements();
$achievements->trigger_engagement( $user_id, $achievement_id, $post_id );
<?php
function my_llms_builder_custom_fields( $fields ) {
$fields['lesson']['my_custom_group'] = array(
// Optional field group title
'title' => __( 'My Custom Field Group', 'my-text-domain' ),
// if the group can be toggled open/closed
'toggleable' => true,
<?php // don't copy this line to your functions.php file!
/**
* Add custom dashboard tabs / urls to the dashboard navigation
* @param array $tabs existing tabs
* @return array
*/
function my_custom_dashboard_tabs( $tabs ) {
// save the signout tab
$signout = $tabs['signout'];
<?php // don't copy this to functions.php file
/**
* Add custom merge codes to an LLMS certificate
* @param int $user_id WP_User ID
* @param int $cert_id WP_Post ID of the generated certificate
* @param int $related_post_id WP_Post ID of the post which triggered the certificate generation
* @return void
*/
function my_custom_cert_merge_codes( $user_id, $cert_id, $related_post_id ) {
<?php // don't copy this to your functions.php file
/**
* Output data for a custom column on the student reporting table/export
* @param string $value default value being output
* @param string $key name of the custom field being output
* @param obj $student LLMS_Student for the row
* @param string $context output context "display" or "export"
* @return mixed
*/
@thomasplevy
thomasplevy / llms-mc-apikey-constant.php
Created February 24, 2021 16:42
Define the MailChimp API key as a constant instead of saving to your site's database (LifterLMS MailChimp)
<?php // Don't copy this line to your wp-config.php file!
// MailChimp
define( 'LLMS_MAILCHIMP_API_KEY', 'YOUR-API-KEY-GOES-HERE' );
@thomasplevy
thomasplevy / llms-auth-dot-net-api-cred-constants.php
Last active January 25, 2021 17:43
Store Authorize.Net API Credentials as constants (in a wp-config.php file, for example) instead of saving them to the WP database (LifterLMS Authorize.Net)
<?php // don't copy this line to your wp-config.php file!
// Sandbox (Test) API Credentails.
define( 'LLMS_AUTH_DOT_NET_TEST_CLIENT_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' );
define( 'LLMS_AUTH_DOT_NET_TEST_LOGIN_ID', 'XXXXXXXXX' );
define( 'LLMS_AUTH_DOT_NET_TEST_TRANSACTION_KEY', 'XXXXXXXXXXXX' );
// Production (Live) API Credentails.
define( 'LLMS_AUTH_DOT_NET_LIVE_CLIENT_KEY', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' );
define( 'LLMS_AUTH_DOT_NET_LIVE_LOGIN_ID', 'XXXXXXXXX' );
@thomasplevy
thomasplevy / llms_mc_enable_consent.php
Created October 14, 2020 15:46
Disable user consent/opt-in to MailChimp lists during LifterLMS user registration