Skip to content

Instantly share code, notes, and snippets.

@onwp
onwp / sample-learndash-query.sql
Created July 28, 2021 08:54 — forked from korynorthrop/sample-learndash-query.sql
Inactive LearnDash user SQL query
SELECT u.user_email,
um.meta_key AS "login_type",
from_unixtime(um.meta_value,'%c/%e/%y') AS "login_date",
GROUP_CONCAT(p.post_title) AS "courses"
FROM nPJeAgtL_users u
INNER JOIN nPJeAgtL_usermeta um ON um.user_id = u.id AND um.meta_key = 'learndash-last-login'
LEFT JOIN nPJeAgtL_learndash_user_activity lua ON lua.user_id = u.id AND lua.activity_type = 'course'
LEFT JOIN nPJeAgtL_posts p ON lua.course_id = p.id
WHERE from_unixtime(um.meta_value) < '2019-03-01 00:00:00' AND p.id IN (1947,1938,7694,1932)
GROUP BY u.user_login
@onwp
onwp / custom results table
Created July 29, 2021 12:14 — forked from peppiekos/custom results table
Custom results table
/*------------------Group leader frontpage table------------------------*/
function group_leader_data() {
ob_start();
$user = wp_get_current_user();
if ( in_array( 'group_leader', (array) $user->roles ) || in_array( 'administrator', (array) $user->roles )) {
$group_leader_id = $user->ID;
$user_group_ids = learndash_get_administrators_group_ids( $group_leader_id, true );
<?php
define( 'WP_USE_THEMES', false );
require( 'wp-blog-header.php' );
$usermeta = get_user_meta( 354, '_sfwd-quizzes', true );
$new = array();
foreach ($usermeta as $key => $value) {
if ( $value['time'] < 1476545002 )
array_push($new, $value);
@onwp
onwp / inspect.php
Created July 31, 2021 22:39 — forked from X-Raym/inspect.php
WordPress inspect styles and scripts
<?php
function inspect_scripts() {
if (!is_admin()) {
global $wp_scripts, $wp_styles;
echo '<h1>Scripts</h1>';
echo '<ol>';
foreach( $wp_scripts->queue as $handle ) :
echo '<li>' . $handle . '</li>';
endforeach;
echo '</ol>';
@onwp
onwp / simple.ses.php
Created August 6, 2021 14:49 — forked from xeoncross/simple.ses.php
Simple SendEmail wrapper for Amazon SES API (does not support SendRawEmail)
<?php
class SES
{
public $accessKey = NULL;
public $accessKeyID = NULL;
public $host = 'https://email.us-east-1.amazonaws.com/';
public $userAgent = 'Test SES Class / v1.0';
public $data = array();
@onwp
onwp / ld-gb-user-grade.php
Created August 27, 2021 00:17 — forked from joelworsham/ld-gb-user-grade.php
LearnDash Gradebook User Grade @ 1.3.6
<?php
/**
* Contains the grade for a given user.
*
* @since 1.0.0
*
* @package LearnDash_Gradebook
* @subpackage LearnDash_Gradebook/includes
*/
@onwp
onwp / snippet.php
Created September 9, 2021 21:46 — forked from lelandf/snippet.php
Add custom field support to LearnDash post types
// https://developer.wordpress.org/reference/functions/add_post_type_support/
add_action( 'init', 'lelandf_custom_fields_support_learndash' );
function lelandf_custom_fields_support_learndash() {
$post_types = [
'sfwd-courses',
'sfwd-lessons',
'sfwd-topic',
];
@onwp
onwp / ld-auto-mark-complete.php
Created September 9, 2021 21:47 — forked from weismannweb/ld-auto-mark-complete.php
Auto complete learndash topics and lessons
//thanks to https://gist.github.com/sultann/24baa5483b4632c3cf214a8de5648204#file-ld-auto-mark-complete-php-L17 for most of
//this code, i just corrected it to work with ld_lesson_tag to grab the tags as the original version returned empty
//array since it was looking for standard wp tags
function ld_is_tagged($postId) {
//get all learndash tags on post
$tags = wp_get_post_terms($postId,'ld_lesson_tag');
foreach ($tags as $tag) {
//need to check for auto-mark-complete tag exists on this post
@onwp
onwp / github-commit-emoji-message.md
Created November 3, 2021 23:40
Github commit emoji message
Commit type Emoji
Initial commit 🎉 :tada:
Readme 👀 :eyes:
Add or update a .gitignore file 🙈 :see_no_evil:
Add or update snapshots 📸 :camera_flash:
Folder .github :octocat: :octocat:
Version tag 🔖 :bookmark:
New feature :sparkles:
Introduce breaking changes 💥 :boom: