hooks for automatic approve user registration according to data in custom fields

## Try this if you are using Woocommerce function ws_new_user_approve_registration_message(){ $not_approved_message=”<p class=”registration”>Send in your registration application today!<br /> NOTE: Your account will be held for moderation and you will be unable to login until it is approved.</p>”; if( isset($_REQUEST[‘approved’]) ){ $approved = $_REQUEST[‘approved’]; if ($approved == ‘false’) echo ‘<p class=”registration successful”>Registration successful! You will be … Read more

Form Submission Not Working In Custom Theme

WordPress uses Name, email post fields to do post comments, If you renamed the your form elements name attributes to be f-name and f-email then your issue will be resolved. I have made changes in below code and it is working now. <?php if($_POST[‘f-submit’]) { if(!$_POST[‘f-name’]) { $error=”<br>- Please enter your name”; } if(!$_POST[‘f-email’]) { … Read more

SQL syntax error. However, it works normally at phpmyadmin

) bracket missing in last condition. (i.e AND (b.meta_key = ‘usage_count’ AND b.meta_value=”0″”); ) $rowcount = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->postmeta AS a, $wpdb->postmeta AS b WHERE a.post_id = b.post_id AND (a.meta_key = ‘customer_email’ AND a.meta_value LIKE ‘%[email protected]%’) AND (b.meta_key = ‘usage_count’ AND b.meta_value=”0″)”); echo $rowcount;

How do I get Woocommerce product variation name and variation description in a WP_Query?

OK, so soon after posting I came up with a working solution. With this code I get the price straight from the variation price field, not from the description field as I mentioned in my question. <?php $params = array(‘posts_per_page’ => -1, ‘post_type’ => ‘product_variation’, ‘order’ => ‘ASC’); $wc_query = new WP_Query($params); global $product; ?> … Read more

Multiple wordpress queries with nested output (odd – even)

Why not just do straight what you’ve wanted. <?php $args_one = array( ‘cat’ => 7, ‘posts_per_page’ => 8, ); $args_two = array( ‘cat’ => 10, ‘posts_per_page’ => 8, ); // will run 2 sql queries. $posts_one = get_posts( $args_one ); $posts_two = get_posts( $args_two ); $all_posts = array(); // lets merge them into 1 array. … Read more

Change menu based on page template via functions.php

The $args the filter is receiving includes the theme_location used when the menu was registered, so assuming your main location is primary, you can add the following to your if statement to target only that menu: if ( is_page_template( ‘page-template-custom.php’ ) && isset( $args[‘theme_location’] ) && ‘primary’ === $args[‘theme_location’] ) ) { … See: https://developer.wordpress.org/reference/hooks/wp_nav_menu_args/ … Read more

Add class to website based on post taxonomy

You can use the body_class filter in WordPress to add the Taxonomy Terms of a Custom Taxonomy as CSS classes to a post. The CSS class appears in the body element and is only used if the post has been assigned to the taxonomy. The code goes in your functions.php file. add_filter( ‘body_class’, ‘themeprefix_add_taxonomy_class’ ); … Read more