Fetch contact-form-7 id to another plugin

Fetch contact-form-7 id to another plugin
Question :
How to fetch contact-form-7 forms ID, to another plugin?
I want to get forms id and using that id, I will give some effect to that form, please tell me how to fetch form id from contact-form-7, to another plugin in wordpress.
Solution code for : Fetch contact-form-7 id to another plugin
Actually in contact form 7,the post type is wpcf7_contact_form So you can use this bellow code . In tis code the function return an array of all contact form's id.
function get_cf7_IDS(){
   $cf7_id_array =array();
    if ( post_type_exists( 'wpcf7_contact_form' ) ) {
      $args = array(
        'post_type' => 'wpcf7_contact_form',
        'posts_per_page'=>-1,
      );
      $the_query = new WP_Query( $args );
      if ( $the_query->have_posts() ) {
        while ( $the_query->have_posts() ) {
          $the_query->the_post();
          $cf7_id_array[]= get_the_ID(); 
        }
        wp_reset_postdata();
      }   
  }
  return $cf7_id_array; //RETURN THE ARRAY OF IDS
}
Then use this function to get all ides in array get_cf7_IDS(). Then let me know the result.

No comments:

Post a Comment