Skip to content

Instantly share code, notes, and snippets.

Prasidhda Malla prasidhda

Block or report user

Report or block prasidhda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Assign separate user roles to super admin and other user to new network site
add_action('wpmu_new_blog', 'wpmudev_new_blog_role', 300, 2);
function wpmudev_new_blog_role( $blog_id, $user_id ) {
//Switch to new network site
switch_to_blog( $blog_id );
//Set default fallback user role
$default_user_role = 'administrator'; // Will be used as fallback user role, will be used if WP somehow can't create user role programitically
//Create free user role
prasidhda / remove-cross-sell-products.php
Last active Nov 27, 2019
Remove cross sell products as well when removing the main product in woo commerce
View remove-cross-sell-products.php
add_action( 'woocommerce_cart_item_removed', function ( $cart_item, $cart ) {
$product_id_cart_item_pairs = WC()->session->get( 'product_id_cart_item_pairs', array() );
$cart_item_product_pairs = WC()->session->get( 'cart_item_product_pairs', array() );
// Get the product ID using session store
$product_id = isset( $product_id_cart_item_pairs[ $cart_item ] ) ? $product_id_cart_item_pairs[ $cart_item ] : false;
if ( ! $product_id ) {
You can’t perform that action at this time.