Skip to content

Instantly share code, notes, and snippets.

@naflan121
naflan121 / wp-auto-login-single-user.php
Created June 12, 2022 14:23 — forked from faceonline/wp-auto-login-single-user.php
Automatically login a single WordPress user upon arrival to a specific page. Redirect to home page once logged in. Prevent viewing the login page. Tested with WP 3.9.1. Used in functions.php
<?php
//Automatically login a single WordPress user upon arrival to a specific page.
//Redirect to home page once logged in and prevent viewing of the login page.
//Tested with WP 3.9.1. Used in functions.php
//Updated 2014-07-18 to resolve WP_DEBUG notice: "get_userdatabylogin is deprecated since version 3.3! Use get_user_by('login') instead."
//From http://tourkick.com/2014/wordpress-demo-multisite-db-reset/
function auto_login() {
//change these 2 items
$loginpageid = '1234'; //Page ID of your login page
@naflan121
naflan121 / download.php
Created March 16, 2022 07:42 — forked from karthikax/dosu.php
PHP Download file to server from URL
<html>
<p style="width: 70%;margin: auto;margin-top: 5%;font-size:larger;text-align:center">
Download a file from any URL</p>
<form method="post" style="width: 70%;margin: auto;margin-top: 10%;">
<input name="url" size="50" placeholder="Source URL" style="width: 100%;height: 10%;font-size: 1.5em;padding:10px" required>
<input name="submit" type="submit" value="Download" style="width: 30%;height: 10%;margin: 5% auto; display: block;">
<p style="width: 70%;margin: auto;margin-top: 10%;font-size:larger;text-align:center">
To <?php echo getcwd(); ?></p>
<p style="width: 70%;margin: auto;font-size: smaller;text-align: center;position: fixed;bottom: 0;background: #fff;">
Powered by: <a href="https://karthikbhat.net/portfolio" target="_blank" style="color:#f60;text-decoration:none;">Karthik</a></p>
@naflan121
naflan121 / WC One Product @ cart
Created March 16, 2020 13:51
Woocommerce Only One Product inside Cart- Emply cart before adding new products
/**
* @snippet WooCommerce Max 1 Product @ Cart- Empty cart before adding new
* @how-to code goes inside functions.php
* @author Random
* @compatible WC 3+
*/
add_filter( 'woocommerce_add_cart_item_data', 'woo_custom_add_to_cart' );