Skip to content

Instantly share code, notes, and snippets.

View amanhstu's full-sized avatar

Amanur Rahman amanhstu

View GitHub Profile
<?php /*Load WP functions and DB access*/
include('wp-load.php');
/*required for wp_user_delete*/
require_once(ABSPATH . 'wp-admin/includes/user.php');
/*Let it run forever*/
set_time_limit(0);
/*Get the $wpdb database object*/
<?php /*Load WP functions and DB access*/
include('wp-load.php');
/*required for wp_user_delete*/
require_once(ABSPATH . 'wp-admin/includes/user.php');
/*Let it run forever*/
set_time_limit(0);
/*Get the $wpdb database object*/
@amanhstu
amanhstu / Bypass Woocommerce logout confirmation Message
Created April 2, 2023 10:31
Bypass Woocommerce logout confirmation Message
/**
* Bypass logout confirmation.
*/
function amanhstu_bypass_logout_confirmation()
{
global $wp;
if (isset($wp->query_vars['customer-logout'])) {
wp_redirect(str_replace('&amp;', '&', wp_logout_url(wc_get_page_permalink('myaccount'))));
exit;
@amanhstu
amanhstu / create-woo-subscription.php
Last active June 14, 2021 14:47
Programmatically create a WooCommerce Subscription and associated WooCommerce Order
<?php
public function give_user_subscription( $product, $user_id, $note = '' ){
// First make sure all required functions and classes exist
if( ! function_exists( 'wc_create_order' ) || ! function_exists( 'wcs_create_subscription' ) || ! class_exists( 'WC_Subscriptions_Product' ) ){
return false;
}
$order = wc_create_order( array( 'customer_id' => $user_id ) );
add_action( 'wp_footer', 'redirect_cf7' );
function redirect_cf7() {
?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'https://www.example.com/thanks/';
}, false );
</script>
<?php
//woocommerce
/*
Show Seller name on the product thumbnail
For WooCommerce
*/
add_action( 'woocommerce_after_shop_loop_item_title','sold_by_vendor_name' );
function sold_by_vendor_name(){
?>
//woocommerce
/*
Show Seller name on the product thumbnail
For WooCommerce
*/
add_action( 'woocommerce_after_shop_loop_item_title','sold_by' );
function sold_by(){
?>
//woocommerce
/*
Show Seller name or store name in the top of Product title from Dokan Plugin
For WooCommerce
*/
add_action( 'woocommerce_before_single_product','sold_by' );
<?php
/**
* The main template file
*/
get_header(); ?>
<?php // Advertisement Placeing Number Functions ?>