How to search order using database frontend short code WordPress

Use the below code it may help you and sure that your sql query is correct then it will be work properly. function wpb_demo_shortcode() { global $wpdb; $results = $wpdb->get_results( $wpdb->prepare(“SELECT DISTINCT o.order_id, o.`order_item_name`, om.`meta_value` as ‘bcs’, (select pm.`meta_value` from `wp_postmeta` as pm WHERE o.order_item_id = om.order_item_id AND pm.`post_id` = o.order_id AND pm.`meta_key` = ‘2-certificate’) … Read more

How do I use a database in a custom theme?

Alright, You did not mention if that data will be stored upon submission from front end or you want to manually put that in. But lets see the way I would handle form submissions and store email addresses. I would use contact form 7 along with its addon Flamingo. It will let you store all … Read more

Create a new account on site B with data from the purchase of site A

I managed to solve via CURL requests via PHP, the code is as follows. functions.php of site A: add_action( ‘woocommerce_order_status_completed’, ‘change_role_on_purchase’ ); function change_role_on_purchase( $order_id ) { $order = new WC_Order( $order_id ); $items = $order->get_items(); foreach ( $items as $item_id => $item ) { $product_id = $item->get_variation_id() ? $item->get_variation_id() : $item->get_product_id(); if ( $product_id … Read more

add role on WordPress in PHP on a second database

I managed to solve after several attempts using the following code: // Insert the role $role = array(‘gold_role’ => 1); $serialized_role = serialize($role); $DB_MEMBERSHIP->insert(‘wpvm_usermeta’, array(‘user_id’ => $user_id, ‘meta_key’ => ‘wpvm_capabilities’, ‘meta_value’ => $serialized_role)); It works very well and doesn’t slow down the shopping experience.