This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = get_users(); | |
foreach( $user as $key => $value){ | |
$course_applied = learn_press_get_user($value->data->ID, false); | |
$profile = learn_press_get_profile( $value->data->ID ); | |
$query_quizzes = $profile->query_quizzes( array( 'status' => '' ,'limit'=>'200' ,'paged' => '1') ); | |
if( !empty( $query_quizzes['items'] ) ): | |
foreach ( $query_quizzes['items'] as $user_quiz ){ | |
$quiz = learn_press_get_quiz( $user_quiz->get_id() ); | |
$quiz_data = $course_applied->get_quiz_data( $quiz->get_id(), $user_quiz->get_course_id() ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = get_users(); | |
foreach( $user as $key => $value){ | |
// /* Get purchased Courses */ | |
global $wpdb; | |
$course_applied = learn_press_get_user($value->data->ID, false); | |
$user_id = $value->data->ID; | |
// $where = array( ); | |
$query = $wpdb->prepare( " | |
SELECT * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Learndash enrollment hook | |
// This code run when the user is enrolling in the course | |
add_action( 'learndash_update_course_access', 'wwc_update_course_access_webinar', 10, 4 ); | |
function wwc_update_course_access_webinar( $user_id, $course_id, $access_list, $remove ){ | |
// if remove = true then unenroll the user else enroll | |
$user_id = get_current_user_id(); | |
if ( ( !empty( $user_id ) ) && ( !empty( $course_id ) ) && ( $remove !== true ) ) { | |
// Write the desired code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// label : Label | |
// value : To save value | |
add_filter('learndash_custom_label_fields', function( $setting_option_fields ){ | |
// Get Learndash Options Array | |
$setting_option_values = get_option('learndash_settings_custom_labels'); | |
$setting_option_values['session_category_label'] = ! isset( $setting_option_values['session_category_label']) ? '' : $setting_option_values['session_category_label']; | |
$session_materials = array( | |
'session_category_label' => array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Thank you page text | |
add_filter('woocommerce_thankyou_order_received_text', 'woo_change_order_received_text', 10, 2 ); | |
function woo_change_order_received_text( $str, $order ) { | |
// Text to change | |
$new_str = 'Thank you for buying, Order received successfully.<br />'; | |
$new_str .= 'To Access your dashboard click here <a class="elementor-button-link elementor-button elementor-size-sm" role="button" href="/dashboard"> | |
<span class="elementor-button-content-wrapper"> | |
<span class="elementor-button-text">My Dashboard</span></span></a>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Buy Only once filter | |
add_filter('woocommerce_add_to_cart_validation','wwc_bought_before_woocommerce_add_to_cart_validation',20, 2); | |
function wwc_bought_before_woocommerce_add_to_cart_validation($valid, $product_id){ | |
$current_user = wp_get_current_user(); | |
if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id)) { | |
wc_add_notice( __( 'You can buy this product only once', 'woocommerce' ), 'error' ); | |
$valid = false; | |
} | |
return $valid; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// init hook | |
add_action('init','create_shortcode_order_details'); | |
function create_shortcode_order_details(){ | |
add_shortcode('shortcode','shortcode_callback'); | |
} | |
// Callback function | |
function shortcode_callback(){ | |
// variable to hold shortcode data mostly html code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Hook for redirect | |
add_action( 'template_redirect', 'woocommerce_custom_redirect_after_checkout'); | |
function woocommerce_custom_redirect_after_checkout(){ | |
// Other Code | |
wp_safe_redirect( site_url("url") ); | |
exit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $user_id Get user Id of the user | |
$courses = learndash_user_get_enrolled_courses( $user_id, array(), true ); | |
// returns array of course IDs | |
?> |