PHP -> SQL Query with Summing

Looking at this, I see that “Paid”, a string, isn’t in quotes. That would cause an error. You can add $wpdb->show_errors() and $wpdb->print_error() methods to reveal that, and any other mysql issues. Also when querying the database, you should use the $wpdb->prepare() method to escape and prepare your variables for query (yes $user->ID probably can’t … Read more

Redirect a WP created page to a manually created PHP file inside theme folder

Maybe you can use query_vars filter and parse_request action. add_action(‘init’, ‘initInternalWPRewrite’, 10); // Add your rewrite rule, you don’t need to create a wordpress page function initInternalWPRewrite () { add_rewrite_rule(‘^diagnostics/?$’, ‘index.php?diagnostics=1’, ‘top’); } add_action(‘init’, ‘rewriteRulesCacheInit’, 10); // This method is useful to avoid manual flush rewrite cache function rewriteRulesCacheInit () { if (!get_option(‘rewrite_rules_cache’)) { add_option(‘rewrite_rules_cache’, … Read more

How to use mysql LIKE with wpdb?

According to the Codex, the delete method will not accept the LIKE operator. You’ll be better off just using the query method. $query = $wpdb->prepare(“DELETE FROM $wpdb->posts WHERE post_type=”flamingo_inbound” AND post_content LIKE %s”, ‘%’.$mail.’%’); $wpdb->query($query); Hopefully $mail doesn’t have a % or _ character otherwise you need to escape it before you build $querylike so: … Read more

Change page password every day (predictable password ;) )

It need not be very complicated. You can simply create a pattern like 2018-09-07-ABC (suffix of ABC) for the date 2018-09-07. Set up the password creation/validation logic like password = md5(‘2018-09-07-ABC’). An administrator if they know the pattern, they can anytime goto any online md5 utility such as http://www.md5.cz and enter the pattern for current … Read more

WP All Import / Update stock quantity from multiple XML files

I managed to get it working, here is answer: – when importing update new stock to custom field: _custom_stock_placeholder – update only this field: _custom_stock_placeholder – add this code to functions.php add_action(‘pmxi_saved_post’, ‘post_saved’, 10, 1); function post_saved($id) { $original_stock = get_post_meta($id, ‘_stock’, true); $new_stock = get_post_meta($id, ‘_custom_stock_placeholder’, true); $combined_stock= $original_stock + $new_stock; update_post_meta($id, ‘_stock’, $combined_stock); … Read more