Get all user meta data by user ID in wordpress

If you want to get all user meta data by using id then use get_user_meta() function.

For example user id is 25. Use the following code for get all user meta data.

  $all_meta_for_user = get_user_meta( 25 );
  print_r( $all_meta_for_user );


Array ( 
[first_name] => Array ( [0] => Tom ) 
[last_name] => Array ( [0] => Auger) 
[nickname] => Array ( [0] => tomauger ) 
[description] => etc.... )

Have any doubt, then comment here!

Do something after WooCommerce order completed

If you want to do something after WooCommerce order completed then use this code.

woocommerce_order_status_completed action hook is a built-in hook of WooCommerce. It allows you to execute a function as when the order is completed. Add your stuff in inside of my_function().

add_action( 'woocommerce_order_status_completed', 'my_function' );
 * Do something after WooCommerce sets an order on completed
function my_function($order_id) {
	// order object (optional but handy)
	$order = new WC_Order( $order_id );
	// do some stuff here

Have any doubt, then comment here!

Create a Custom WordPress Plugin

To start, create a new folder in your “wp-content/plugins” folder called “my-plugin”. Then create a new file within this folder called “myplugin.php” and place this code:

Plugin Name: my plugin
Plugin URL:
Description: A simple WordPress plugin
Version: 1.0
Author: Boopathi Rajan
Author URI:

If you refresh your administration panel’s plugin page, you’ll now see our plugin listed along with the other ones.Let’s go and activate our plugin by clicking Activate to the right of the plugin entry.

Have any doubt, then comment here!

How to add wordpress color picker in custom plugin development

WordPress has added a color picker in the core code from WordPress v3.5.Plugin developers can now take advantage of this and add a color picker easily in their plugin

How to Add Color Picker

Step 1) Create a java script named as color-script.js and place this code:

var myOptions = {
// you can declare a default color here,
// or in the data-default-color attribute on the input
defaultColor: false,
// a callback to fire whenever the color changes to a valid color
change: function(event, ui){},
// a callback to fire when the input is emptied or an invalid color
clear: function() {},
// hide the color picker controls on load
hide: true,
// show a group of common colors beneath the square
// or, supply an array of colors to customize further
palettes: true

Step 2) Enqueue the “wp-color-picker” jquery script

add_action( 'admin_enqueue_scripts', 'mw_enqueue_color_picker' );
function mw_enqueue_color_picker( $hook_suffix ) {
// first check that $hook_suffix is appropriate for your admin page
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'my-script-handle', plugins_url('js/color-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );

My plugin now has a color-script.js file that has declared wp-color-picker as a dependency. We can now use the wpColorPicker jQuery method inside it.

Step 3) Add an input (example: text input) to the interface where you want the color picker

<input type="text" value="#abc" class="my-color-field"/>

You can also specify a default color for the field (this will be selected by default):

<input type="text" value="#bada55" data-default-color="#abc" class="my-color-field"/>

That’s it. Your users will now be able to choose a color from the color picker

Have any doubt, then comment here!