Posts

Showing posts from August, 2015

How to add a shortcode button to wordpress page or post editor tinymce

Just copy and paste below code into your theme's functions.php file or your custom plugin's file and change according to your shortcode. add_action( 'init', 'rj_ctn_buttons' ); function rj_ctn_buttons() {     add_filter( "mce_external_plugins", "rj_add_ctn_buttons" );     add_filter( 'mce_buttons', 'rj_register_ctn_buttons' ); } function rj_add_ctn_buttons( $plugin_array ) {     $plugin_array['rj_ctn'] = get_stylesheet_directory_uri() . '/js/rj-ctn-plugin.js';  //include shortcode plugin js file in tinymce plugins     return $plugin_array; } function rj_register_ctn_buttons( $buttons ) {     array_push( $buttons, 'ctn' );  // add button to tinymce buttons     return $buttons; } and my rj-ctn-plugin.js file is as below (function() {     tinymce.create('tinymce.plugins.Rj_ctn', {         init : function(ed, url) {             ed.addButton...

How to change user id on checkout page for assign order to different user in woocommerce wordpress

Just copy and paste below code into your theme's functions.php file or in your custom plugin file function rj_replace_user_id_with_session_id(){     if(!session_id()){         session_start();     }     if(isset($_SESSION['order_replace_by_user_id'])){            return $_SESSION['order_replace_by_user_id']; // return user id you want to assign order     } } add_filter( 'woocommerce_checkout_customer_id', 'rj_replace_user_id_with_session_id' );