How do you get final outputed HTML in PHP?

The typical way to get “the entire page worth of HTML” is to use the template_redirect hook, it’s often used for “run-time find & replace” methods. If I ever need to use it, I just use it in an Anonymous Function. add_action( ‘template_redirect’, function(){ ob_start( function( $buffer ){ // Do whatever to $buffer – it … Read more

PHP Array Returning [object Object]. Tried existing answers results with no luck

Let’s try the below code, $users = get_all_user_ids(”); $i=0; // initialization foreach($users as $user) { $pageview = get_user_meta($user, ‘page_visits’, true); if ($pageview != 0) { //$popularid[$pageview][‘count’] = $user; // Err: // Array won’t be unique due to pageview might be same for multiple users // $popularid[$user] = $pageview; // Array will be unique based on … Read more

WooCommerce: How can I get orders with a custom ID in order meta data object?

You would add the meta_query portion to your wc_get_orders() as the only filter … function woocommerce_account_orders( $current_page ) { $current_page = empty( $current_page ) ? 1 : absint( $current_page ); $customer_orders = wc_get_orders( apply_filters( ‘woocommerce_my_account_my_orders_query’, array( ‘page’ => $current_page, ‘paginate’ => true, ‘meta_query’ => array( array( ‘key’ => ‘mycustom_id’, ‘value’ => get_current_user_id(), ‘compare’ => ‘=’ … Read more

Set meta field to publish date + 2 weeks

Try this: add_action(‘publish_post’, ‘dp_expiry’); function dp_expiry( $data ) { /*adds 2 weeks onto the current date in unix epoch format*/ $dp_new_expiry_date = (strtotime( current_time( ‘mysql’ ) ) + 1209600); /*converts unix timstamp back to yyyy-mm-dd format like you required*/ $dp_new_expiry_date_conv = date(“Y-m-d”, $dp_new_expiry_date); update_post_meta( $data[‘post_id’], ‘postexpiry’, $dp_new_expiry_date_conv ); }