Skip to content

Instantly share code, notes, and snippets.

@arsalan13nov
arsalan13nov / Hide WooCommerce Product Price
Created August 29, 2017 23:15
Snippet to hide price on WooCommerce products in selected category.
/**** Custom Code to hide product prices based on the associatin with specific categories. ****/
/**** Place the following code at the bottom of theme's functions.php file. ****/
/**
* Remove price on product detail page
*
* @param none
* @return none
*/
function remove_prices_based_on_category() {
@arsalan13nov
arsalan13nov / Display media for download (General)
Created August 31, 2017 00:16
Snippet to add a shortcode that displays the media for download.
/**** Custom Shortcode to display media file download link. ****/
/**** Place the following code at the bottom of theme's functions.php file. ****/
/**** Sample Shortcode usage: [ld_download_media_file file_url="https://www.w3schools.com/html/mov_bbb.mp4" file_icon="fa-play-circle" file_title="Some File"]
/**
* Display the link of the media file for download.
*
* @param $atts - Shortcode attributes
* @return string
*/
@arsalan13nov
arsalan13nov / Disable Payapl on WC Checkout
Created September 14, 2017 22:16
Selectively disable PayPal on Subscription products for WooCommerce
/**** Custom Code to remove Paypal Payment method on checkout if cart contains subscription products. ****/
/**** Place the following code at the bottom of theme's functions.php file. ****/
/**
* Remove Paypal method from Checkout.
*
* @param $gateway_list Contains payment methods array.
* @return $gateway_list Contains payment methods array.
*/
function woocs_filter_gateways( $gateway_list )
// Fetch the users from the CSV
$file = fopen('report.csv', 'r');
while(! feof($file))
{
$v = fgetcsv($file); //print_r(fgetcsv($file));
$user_ids[] = $v[0];
}
// Remove duplicates
$user_ids = array_unique( $user_ids );
@arsalan13nov
arsalan13nov / LearnDash Redirect on Course Completion
Created September 21, 2018 21:38
LearnDash Redirect on Course Completion
// Adding Custom Redirection field in LD Courses
add_filter( 'learndash_post_args', 'add_topic_option' );
function add_topic_option( $post_args ) {
// New Course field to add redirection link.
$redirect_on_completion = array(
'redirect_on_completion' => array(
'name' => __( 'Redirect on Completion', 'learndash' ),
'type' => 'text',
'initial_options' => '',
@arsalan13nov
arsalan13nov / LearnDash Post Arguments
Created November 5, 2018 04:42
LearnDash Post Arguments
// Adding Custom Configuration field in LearnDash Topics
add_filter( 'learndash_post_args', 'add_topic_option' );
function add_topic_option( $post_args ) {
global $pagenow;
$topic_id = $_GET['post'];
// If in Topic Edit Screen
if ( $pagenow == 'post.php' && get_post_type( $topic_id ) == 'sfwd-topic' ) {
@arsalan13nov
arsalan13nov / gist:cf4a168590aa2f941b32c922ba8b620c
Created January 9, 2019 20:04
Reset Users Course Progress LearnDash
// REST Code
function oddc_learndash_delete_user_activity( $user_id ) {
if( empty( $user_id ) )
return false;
global $wpdb;
$users = $wpdb->get_results( $wpdb->prepare( "SELECT activity_id FROM ". $wpdb->prefix ."learndash_user_activity WHERE user_id = %d ", $user_id ), ARRAY_A );
if( !empty( $users ) ) {