Showing posts with label WordPress. Show all posts
Showing posts with label WordPress. Show all posts

Friday, October 11, 2024

Create an admin account in WordPress via MySQL

INSERT INTO `wp_users`(

    `user_login`,

    `user_pass`,

    `user_nicename`,

    `user_email`,

    `user_status`

)

VALUES(

    'admin999',

    MD5('password999'),

    'firstname lastname',

    'email@example.com',

    '0'

);

INSERT INTO `wp_usermeta`(

    `umeta_id`,

    `user_id`,

    `meta_key`,

    `meta_value`

)

VALUES(

    NULL,

    (

SELECT

    MAX(id)

FROM

    wp_users

),

'wp_capabilities',

'a:1:{s:13:"administrator";s:1:"1";}'

);

INSERT INTO `wp_usermeta`(

    `umeta_id`,

    `user_id`,

    `meta_key`,

    `meta_value`

)

VALUES(

    NULL,

    (

SELECT

    MAX(id)

FROM

    wp_users

),

'wp_user_level',

'10'

);

Wednesday, March 13, 2024

WordPress website Migration & Restore using All-In-One-WP-Migration

Copy cPanel to cPanel internal server Migration

cp /home/Source-cPanel-username/public_html/wp-content/ai1wm-backups/your-backup-file-name.wpress /home/Target-cPanel-username/public_html/wp-content/ai1wm-backups


 Copy cPanel to cPanel Different server Migration


1. cd /home/Target-cPanel-username/public_html/wp-content/ai1wm-backups

2. wget use-source-url-https-link


All in One WP Migration Download

Tuesday, April 19, 2022

Decrease product price by 10% using SQL command in Woocommernce from Phpmyadmin

 Query-1:

UPDATE

   wp_wc_product_meta_lookup

SET

    min_price =(min_price - min_price * .13)

WHERE 1;

Query-2;

 UPDATE

   wp_wc_product_meta_lookup

SET

    max_price =(max_price - max_price * .13)

WHERE 1;

Friday, March 11, 2022

How to Delete All Products in WooCommerce using SQL Command?

  1. Log in to the phpMyAdmin portal
  2. Select the database that has all the products to be deleted. Make sure, that you backup your database before executing the SQL statement!
  3. Than select table {prefix}_posts and run the SQL statement as shown.


DELETE relations.*, taxes.*, terms.*

FROM metro4u_term_relationships AS relations

INNER JOIN metro4u_term_taxonomy AS taxes

ON relations.term_taxonomy_id=taxes.term_taxonomy_id

INNER JOIN metro4u_terms AS terms

ON taxes.term_id=terms.term_id

WHERE object_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));


DELETE FROM metro4u_postmeta WHERE post_id IN (SELECT ID FROM metro4u_posts WHERE post_type IN ('product','product_variation'));

DELETE FROM metro4u_posts WHERE post_type IN ('product','product_variation');


Note: "metro4u" is a prefix. Set your Database Table prefix

Tuesday, December 28, 2021

How to Allow WebP Upload in WordPress using Function

//enable upload for webp image files.

function webp_upload_mimes($existing_mimes) {

    $existing_mimes['webp'] = 'image/webp';

    return $existing_mimes;

}

add_filter('mime_types', 'webp_upload_mimes');


//enable preview / thumbnail for webp image files.

function webp_is_displayable($result, $path) {

    if ($result === false) {

        $displayable_image_types = array( IMAGETYPE_WEBP );

        $info = @getimagesize( $path );


        if (empty($info)) {

            $result = false;

        } elseif (!in_array($info[2], $displayable_image_types)) {

            $result = false;

        } else {

            $result = true;

        }

    }


    return $result;

}

add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

function webp_upload_mimes($existing_mimes) {
    $existing_mimes['webp'] = 'image/webp';
    return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');

//enable preview / thumbnail for webp image files.
function webp_is_displayable($result, $path) {
    if ($result === false) {
        $displayable_image_types = array( IMAGETYPE_WEBP );
        $info = @getimagesize( $path );

        if (empty($info)) {
            $result = false;
        } elseif (!in_array($info[2], $displayable_image_types)) {
            $result = false;
        } else {
            $result = true;
        }
    }

    return $result;
}
add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2);

Wednesday, November 3, 2021

Create Admin user for WordPress Using function

 


function wpb_admin_account(){

$user = 'sadmin';

$pass = '123456';

$email = 'username@yourdomain.com';

if ( !username_exists( $user )  && !email_exists( $email ) ) {

$user_id = wp_create_user( $user, $pass, $email );

$user = new WP_User( $user_id );

$user->set_role( 'administrator' );

} }

add_action('init','wpb_admin_account');

How to get Ranking of the Students in Excel using RANK Function

=RANK(number,ref,[order]) To rank in descending order, we will use the formula =RANK(B2,($C$5:$C$10),0) If we want unique ranks, we can use...