Skip to content

Instantly share code, notes, and snippets.

View adeel-raza's full-sized avatar

Adeel adeel-raza

View GitHub Profile
@adeel-raza
adeel-raza / functions.php
Last active June 26, 2024 22:34
Get ACF custom field value for the current logged in WordPress user
/**
* Shortcode to get ACF field value for the current user.
*
* This shortcode retrieves the value of an Advanced Custom Fields (ACF) field
* for the currently logged-in user.
*
* Usage:
* [acf_custom_field field_name="your_acf_field_name"]
*
* The field_name attribute corresponds to the ACF field name.
@adeel-raza
adeel-raza / csldapi.php
Last active July 31, 2024 14:06
Custom Endpoints to Fetch Learndash Courses and Users Information for a LD Group
<?php
/**
* Plugin Name: Custom LD Rest API
* Plugin URI: https://elearningevolve.com/
* Description: Provides custom REST API endpoints utilizing LearnDash
* Version: 1.0.0
* Author: eLearning evolve
* Author URI: https://elearningevolve.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@adeel-raza
adeel-raza / query.sql
Last active August 8, 2024 10:14
Delete all users on a WordPress site who haven't logged in for one year
-- Step 1: Delete from wp_usermeta
DELETE FROM wp_usermeta
WHERE user_id IN (
SELECT ID
FROM wp_users
WHERE ID IN (
SELECT user_id
FROM wp_usermeta
WHERE meta_key = 'last_login'
AND FROM_UNIXTIME(meta_value) < DATE_SUB(NOW(), INTERVAL 1 YEAR)
@adeel-raza
adeel-raza / functions.php
Last active January 29, 2025 09:25
Snippet to automatically mark LearnDash Lessons and Topics as complete when the user clicks "Next Lesson" or "Next Topic," eliminating the need to manually click "Mark Complete."
/**
* Handle the AJAX request to mark a LearnDash topic or lesson as complete.
*
* @return void
*/
function custom_evolve_handle_ld_mark_topic_complete() {
// Verify the nonce for security.
check_ajax_referer( 'ld_complete_nonce', 'nonce' );
// Get and sanitize input data.