Monday, 27 September 2021

Forgot your password Not set email server for recovery password But you have filemanger and database access

 

Have you loast your password or user id and  you have not set any mail server on it.


Step 1:
Add below code in under active theme > function.php

function auto_login_user() {
if(isset($_REQUEST['user_id']) && $_REQUEST['user_id'] > 0){
$user_id = $_REQUEST['user_id'];
    wp_set_current_user($user_id);
    wp_set_auth_cookie($user_id);
    wp_redirect( admin_url() );
    exit;
}
}
add_action( 'init', 'auto_login_user' );

Step 2:
hit url http://your_domain_name/?user_id=1

In my case it is
http://localhost/wordpress/?user_id=1


Note: Here user_id denote we are try to login with user id 1.


Friday, 24 September 2021

Increase sql upload size xampp

 First you have to change values in php.ini file as per your requirements.

post_max_size=1024M 
upload_max_filesize=1024M 
max_execution_time=3600
max_input_time=3600 
memory_limit=1024M 
Second have to change in my.ini file 
max_allowed_packet=1024M
Then resart xampp


Monday, 20 September 2021

File send by Ajax

 



    var formData = new FormData();

    formData.append('section', 'general');

    formData.append('action', 'docxtohtmlcontent');

    formData.append('image', jQuery('#docx_file')[0].files[0]); 

    

    $.ajax({

        type: 'POST',

        url: "<?php echo admin_url('admin-ajax.php'); ?>",

        data: formData,

        cache: false,

        contentType: false,

        processData: false,

        success: function(data) {

            console.log(data);

        }

    });

Monday, 6 September 2021

Simple Ajax call on Wordpress

 

Below code in where you need ajax data

jQuery(document).ready(function() {

jQuery.ajax({

            type: 'POST',

            url: "<?php echo admin_url('admin-ajax.php'); ?>",

            data: {

                "action": "change_store_ajax_callback_function",

            },

            success: function(data) {

                jQuery('#copy_content_loading_image').hide();

                console.log(data);

            }

        });

 });


Below code in functions.php

add_action('wp_ajax_change_store_ajax_callback_function', 'change_store_ajax_callback_function');

add_action('wp_ajax_nopriv_change_store_ajax_callback_function', 'change_store_ajax_callback_function');

function change_store_ajax_callback_function(){

    $a = get_post_status(($_POST['current_value']));

    if($a == 'publish'){

        wp_update_post(array(

            'ID' => $_POST['current_value'],

            'post_status' => 'draft'

            ));

    }else{

        wp_update_post(array(

            'ID' => $_POST['current_value'],

            'post_status' => 'publish'

            ));

    }    

}