Categories
CMS Mastering Development Wordpress

How to trigger a function when submit a form

How can I make work these functions not just when the user profile is updated. Also when a frontend form is submited? Here the functions: function get_channel_by_author( $user_id ) : int { // if we don’t find anything then a value of 0 will create a new post rather than update an existing post. $channel_id […]

Categories
CMS Mastering Development Wordpress

What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?

I am trying to create a custom post type input using the wp_insert_post function, this custom post type called game was created using the pods framework and contains a series of custom fields which I try to give values using the meta_input key as follows Example using _pods_ prefix $entry = [ "post_title" => "{$post->post_title} […]

Categories
CMS Mastering Development Wordpress

After creating Custom post type by user delete old one

I have created a form where users update their profile. When a profile is created or updated it creates a CPT called course. The url is the permalink + /course/ + the title of the course /* CREATING COURSE PAGES FROM USER PROFILES */ function create_course_page( $user_id = ” ) { $user = new WP_User($user_id); […]

Categories
CMS Mastering Development Wordpress

Why add_action work only one time?

i have a function that create a page programmatically if a new value it s added on db. add_action("init", "mic_create_new_page", 10); function mic_create_new_page() { global $wpdb; $res = $wpdb->get_results(‘select * from ‘.$wpdb->prefix. ‘ mic_secteurs’); foreach ( $res as $ville ) { $id = $ville->id_secteurs; $secteur = $ville->libelle; $slugmic = strtolower(str_replace(" ","-",$secteur))."-s". $id ; global $user_ID; […]

Categories
CMS Mastering Development Wordpress

After creating Custom post type by user delete old one

I have created a form where users update their profile. When a profile is created or updated it creates a CPT called course. The url is the permalink + /course/ + the title of the course /* CREATING COURSE PAGES FROM USER PROFILES */ function create_course_page( $user_id = ” ) { $user = new WP_User($user_id); […]

Categories
CMS Mastering Development Wordpress

all values not stock in array after request

I m working on a plugin. I get some values from db and put in array for create programmatically some pages. So, before the creation; he match the name in the array with the value of db if not exist, it goes to create a new page. But not all values are taken and the […]

Categories
CMS Mastering Development Wordpress

How to create a page with the selected template after activating the plugin

I’m writing my first plugin and I have problem. I don’t know how to write function, which create page with selected specific template after activate plugin. function add_my_custom_page() { // Create post object $my_post = array( ‘post_title’ => wp_strip_all_tags( ‘Example form’ ), ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_type’ => ‘page’, ); // Insert the […]

Categories
CMS Mastering Development Wordpress

wp insert post not working

my wp insert post not working. In post_title and post_name he not save the variable. So at place of Service + variable , i get only "Service", why? function mic_create_new_page() { global $user_ID; $new_post = array( ‘post_title’ => ‘Service ‘ . $secteur, ‘post_content’ => ‘[makeitseo-keyword]’, ‘post_status’ => ‘publish’, ‘post_date’ => date(‘Y-m-d H:i:s’), ‘post_author’ => $user_ID, […]

Categories
CMS Mastering Development Wordpress

Product Variation not showing correct term name on admin

I have created a product variation programmatically using this code block private function createProductVariation($product_id, $variation_data) { // Get the Variable product object (parent) $product = wc_get_product($product_id); $variation_post = array( ‘post_title’ => $product->get_name(), ‘post_name’ => ‘product-‘ . $product_id . ‘-variation’, ‘post_status’ => ‘publish’, ‘post_parent’ => $product_id, ‘post_excerpt’ => $variation_data[‘attributes’], ‘post_type’ => ‘product_variation’, ‘guid’ => $product->get_permalink() ); […]

Categories
CMS Mastering Development Wordpress

How can i avoid duplicate same post in wp?

I m working on a wp plugin and i have 3 tables. In my plugin i have two different loop: both of them create programmatically a page from my tables. My problem is that if i refresh the page, it duplicate my pages. How can i avoid this? I have tried with get post title […]