Custom plugin issue – Notice: Trying to get property of non-object in

try use global $post; at the beginning of your function Note that you’ve to run on a specific hook in order to work. see this post: https://www.ibenic.com/how-to-add-woocommerce-custom-product-fields/ function spinna360_nof() { $noy=array( ‘id’ => ‘_select_noi’, ‘label’ => __( ‘Select number of images: ‘, ‘spinna360’ ), ‘selected’ => true, ‘options’ => [ ’24’ => __( ’24’, ‘spinna360’ … Read more

How to iterate on a list?

To do this without coding will be difficult. Contact Form 7 is meant to send out emails after form submission, not much more. You need a callback function that you can use to implement your coupon logic. One possible solution: Install the Redirect Addon for Contact Form 7 and configure it to redirect to a … Read more

How to allow editors to only edit certain categories?

You can hook into the pre_post_update action hook, and check both post’s category and editor. Here’s a quick example: // Hook to save_post to do some checks add_action( ‘pre_post_update’,’wpse315124_save_post_check’ ); function wpse315124_save_post_check( $post_id, $post_data ){ // Check user’s role and post’s category if( has_category ( ‘some-category’, $post_id ) && current_user_can( ‘editor’ ) ) { // … Read more

WordPress showing fatal error on wp_set_object_terms line

wp_insert_term returns an array on success or a WP_Error in case of problems. You should catch the error and look for the reason why it fails. One problem could be, how you create the slug, because it could lead to an error during the creation of the term. Just use $slug = sanitize_title( $T_product_type ) … Read more