I need to check if the current post is belongs to a category then insert some data in a table (already created) if a term selected.
In human readable format, I was expecting to do something like this:
If Education category selected, insert “data” in table requests
I’ve tried this code but I’ve nothing registered in my table
global $wpdb, $current_user;
get_currentuserinfo();
$uid = $current_user->ID;
$pid = $_GET['auction_id'];
$tm = current_time('timestamp',0);
$auction_cat = wp_get_object_terms($pid, 'auction_cat');
$cate = array($auction_cat[0]->term_id);
// check if the category of auction is University_Id = 4
if (in_array(4, $cate))
{
$wpdb->query("insert into ".$wpdb->prefix."auction_requests (pid, uid, datemade) values('$pid','$uid',$tm')");
}
Any help will be appreciated! Thanks in advance