Skip to content

Instantly share code, notes, and snippets.

View j2machado's full-sized avatar
💻
Creating Cool Stuff

Juan José Machado j2machado

💻
Creating Cool Stuff
View GitHub Profile
@j2machado
j2machado / ld-show-the-login-form-first-on-page-load.php
Last active May 5, 2025 13:35
Show the Login Form first in the LearnDash Registration form
<?php
/*
* Show the Login Form first on the Registration page.
*/
add_action( 'wp_footer', function () {
// Get the LearnDash registration page ID.
$ld_registration_page_id = learndash_registration_page_get_id();
// Exit if user is already logged in or not on the registration page.
@j2machado
j2machado / functions.php
Last active May 3, 2022 17:57
LearnDash - In a course with Closed Access Mode, redirect the unenrolled users to the Button URL value, e.g. a WooCommerce Product or a Landing Page to purchase the course
<?php
/* In LearnDash, prevent unenrolled users from reaching
the single course page and redirect them to the Button URL value */
/* TO DO
* - Add support for groups
* - Add an option in LearnDash settings to turn on/off.
* - Add support for externa URLs as well (Unbounce, Click Funnels, etc).
*/
@webmasterninjay
webmasterninjay / downloader.php
Created September 26, 2019 14:33
Simple PHP script to download file from url
<html>
<form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
<?php
// maximum execution time in seconds
set_time_limit (24 * 60 * 60);
if (!isset($_POST['submit'])) die();
@mattclements
mattclements / function.php
Last active May 15, 2025 08:56
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@webmasterninjay
webmasterninjay / functions.php
Created July 10, 2015 14:41
Woocommerce - Redirect after payment
<?php
/* Redirect user after check out */
add_action( 'template_redirect', 'jay_custom_redirect_after_purchase' );
function jay_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://www.yoururl.com/your-page/' );
exit;
anonymous
anonymous / gmaps-drawing-tools-places.htm
Created July 1, 2015 04:54
gmaps-drawing-tools-places.htm
<!DOCTYPE html>
<!-- http://gmaps-samples-v3.googlecode.com/svn/trunk/drawing/drawing-tools.html -->
<!-- https://developers.google.com/maps/documentation/javascript/examples/places-searchbox -->
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Drawing Tools (B)</title>
<!-- NOTE: two libraries to load are comma-separated; otherwise last mention of the query string arg overwrites the previous -->
<script type="text/javascript"