Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function edit_user_hours($post){
- $post_id = $post->ID;
- $customer_id = get_current_user_id();
- if ( !get_post_meta( $post_id, 'firstpublish', $single = true ) ) {
- // ...run code once
- $get_table = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_woocommerce_userHours WHERE userId = %s LIMIT 1", $customer_id));
- $get_table = $get_table[0];
- $mykey_values = get_post_custom_values( 'hours_taken' );
- foreach ( $mykey_values as $key => $value ) {
- $hourBlock = $value - $get_table->hourBlocks;
- }
- // Do something!
- $wpdb->query($wpdb->prepare("UPDATE wp_woocommerce_userHours SET userHours = userHours + $hourBlock WHERE userId = %s LIMIT 1", $customer_id));
- die('Data inserted');
- update_post_meta( $post_id, 'firstpublish', true );
- }
- }
- add_action( 'draft_to_published', 'a_new_post' )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement