admin管理员组

文章数量:1327959

I am new to PHP. Please help me to achieve the below scenario. I am trying to achieve this from the last 3 days.

I've two categories in my WordPress dashboard named "Available (id:3)" and "Booked (id:4)". In the "available" category a few numbers are there as posts.

In each post page contact 7 form is embedded.

When I submit a "contact form 7" successfully from that post, I would like to move that current post to the "booked" category.

Please check the link and click any numbers for what I am looking for.

'Available' category: / 'Booked' category:/

I tried something like below in my functions.php and not working at all.

add_action('wpcf7_mail_sent', function ($cf7) {
    $category_id = get_cat_ID('available');
    $post_id = get_the_ID();
    wp_remove_object_terms( $post_id, 'available', 'category');
    wp_set_object_terms( $post_id, 'booked', 'category');
});

本文标签: categoriesHow to change current category to another in wordpress