Woocommerce: change user role after completing order

Looking through the code there is a very relevant example: function woocommerce_paying_customer( $order_id ) { $order = new WC_Order( $order_id ); if ( $order->user_id > 0 ) { $old_spent = absint( get_user_meta( $order->user_id, ‘_money_spent’, true ) ); update_user_meta( $order->user_id, ‘_money_spent’, $old_spent + $order->order_total ); $old_count = absint( get_user_meta( $order->user_id, ‘_order_count’, true ) ); update_user_meta( $order->user_id, … Read more

How to fetch serialized data from wordpress options

No, this won’t work: <?php echo get_option(‘notice_data[Message]’); ?> Because get_option pulls whole option value by option_name, it doesn’t pull by pieces of the serialized array. What you are asking for is a key (option_name) called literally notice_data[Message]. Assuming you’ve saved the option as notice_data you aren’t going to get a match, and I am not … Read more

Change destination author link

To only edit the link associated with authors, in the functions.php of your theme: add_filter( ‘author_link’, ‘new_author_link’, 10, 1 ); function new_author_link( $link ) { $link = ‘http://newlink.com/’; //set this however you wish return $link; //after you’ve set $link, return it to the filter } If you’re looking to do something like set each author’s … Read more

How to list the Hooks and order of execution in current loading page? [duplicate]

Paste this into your functions.php //LIST ALL HOOKS function dump_hook( $tag, $hook ) { ksort($hook); echo “<pre>>>>>>\t$tag<br>”; foreach( $hook as $priority => $functions ) { echo $priority; foreach( $functions as $function ) if( $function[‘function’] != ‘list_hook_details’ ) { echo “\t”; if( is_string( $function[‘function’] ) ) echo $function[‘function’]; elseif( is_string( $function[‘function’][0] ) ) echo $function[‘function’][0] . … Read more