Hi, i have imported in WP a CFV6 form created with Joomla. Everythings seems to be fine, but I have two main problems with CFV6 and WP.
1) I'm not able to integrate the form in a PHP template file, that's the code:
2) In the load section i set a PHP action to include a custom PHP file. The problem here is that I can't access the $this->data object in the included file because I get the following error:
I include the PHP file the same way as I included it in Joomla (except that 'JPATH_ROOT' was replaced with 'site_url()') with:
Thanks.
1) I'm not able to integrate the form in a PHP template file, that's the code:
<?php echo do_shortcode('[Chronoforms6 chronoform="search"]') ?>The shortcode [Chronoforms6 chronoform="search"] works great only in pages and articles.
2) In the load section i set a PHP action to include a custom PHP file. The problem here is that I can't access the $this->data object in the included file because I get the following error:
PHP Fatal error: Using $this when not in object contextTo be noted that the same form, works great in Joomla where I can use the $this->data without problem also in the included PHP file.
I include the PHP file the same way as I included it in Joomla (except that 'JPATH_ROOT' was replaced with 'site_url()') with:
include_once(site_url() . '/myfolder/myfile.php');
Thanks.
I solved the 2nd problem by replacing site_url() with ABSPATH
not sure about #1, what about other plugins ? they work with the same code ?
Yes it works. For example I can display a Contact Form with:
<?php echo do_shortcode('[contact-form-7 id="12" title="Contact form"]'); ?>Take a look at wordpress code reference here https://developer.wordpress.org/reference/functions/do_shortcode/
try to include/require the Chronoforms6 php file in the plugins folder, does it help ?
Hi max, thanks for reply, I try to include chronoforms6.php with:
But I get the following error:
include ABSPATH . "wp-content/plugins/chronoforms6/chronoforms6.php";
echo do_shortcode('[Chronoforms6 chronoform="search"]');
But I get the following error:
Fatal error: Cannot declare class Chronoforms6, because the name is already in use in C:\xampp\htdocs\wordpress\wp-content\plugins\chronoforms6\chronoforms6.php on line 12
change your include line to this:
if(!class_exists("Chronoforms6")){//include line here}
The error disappears, but file is not included and form is not displayed.
<?php
if(!class_exists("Chronoforms6")) {
include ABSPATH . "wp-content/plugins/chronoforms6/chronoforms6.php";
echo "INCLUDED";
} else {
echo "NOT INCLUDED";
}
echo do_shortcode('[Chronoforms6 chronoform="search"]');
?>
Ok, try this line before your do_shortcode line:
add_shortcode('Chronoforms6',array(new Chronoforms6(),'cf6_getform'));
Also, why do not you just place the form inside a page/post then call that post in your template ? does that work ?
[blockquote]Ok, try this line before your do_shortcode line:
add_shortcode('Chronoforms6',array(new Chronoforms6(),'cf6_getform'));[/blockquote]
Not work.
I'm pretty new to WP so I don't know how to properly include a page/post in theme template. Anyway I have inserted the CFV6 Shortcode [Chronoforms6 chronoform="search"] in an article and here the form is displayed right.[br][br]When I try to show that article in my theme, I can see only the text of the article "Welcome to WordPress. This is your first post...", but not the form. I use the following code:
add_shortcode('Chronoforms6',array(new Chronoforms6(),'cf6_getform'));[/blockquote]
Not work.
Also, why do not you just place the form inside a page/post then call that post in your template ? does that work ?
I'm pretty new to WP so I don't know how to properly include a page/post in theme template. Anyway I have inserted the CFV6 Shortcode [Chronoforms6 chronoform="search"] in an article and here the form is displayed right.[br][br]When I try to show that article in my theme, I can see only the text of the article "Welcome to WordPress. This is your first post...", but not the form. I use the following code:
$post = get_post( 1 ); -->> HELLO WORLD with Chronoforms6 ShortCodeIn the print_r($post) I can see in 'post_content' the Chronoforms6 shortocode, but is not displayed in the view
print_r($post);
$output = apply_filters( 'the_content', $post->post_content );
echo $output;
I trie also to insert shortcode in widget without luck. It seems that CFV6 works only on pages and article.
There are other posts for that issue:
- http://www.chronoengine.com/forums/posts/t107789/wordpress-choronoforms-v6-shortcode-works-in-pages-not-widgets
- http://www.chronoengine.com/forums/posts/t108139/chronoforms6-not-display-forms-on-wordpress
Maybe CFV7 solve that problem? I trie to download the V. 7 RC1 from the download section but I get the error "File does not exist."
There are other posts for that issue:
- http://www.chronoengine.com/forums/posts/t107789/wordpress-choronoforms-v6-shortcode-works-in-pages-not-widgets
- http://www.chronoengine.com/forums/posts/t108139/chronoforms6-not-display-forms-on-wordpress
Maybe CFV7 solve that problem? I trie to download the V. 7 RC1 from the download section but I get the error "File does not exist."
Try this code:
if(class_exists('Chronoforms7')){by the way, I'm testing using the default twentynineteen theme on WP, which file you are modifying for testing ?
$Chronoforms6 = new Chronoforms6();
echo $Chronoforms6->cf6_render(['chronoform' => 'test-form'];
}
Thank you Max, now it works!!
I'm working on Flatsome theme and I'm modifying a file used to display WooCommerce categories, called 'category-off-canvas.php'.
Any way, thank you soo much for your support. I'm really excited to try the new CFV7 version.
I'm working on Flatsome theme and I'm modifying a file used to display WooCommerce categories, called 'category-off-canvas.php'.
Any way, thank you soo much for your support. I'm really excited to try the new CFV7 version.
Great news!🙂
the new v7 for WP is already available for download on the downloads page if you want to try it, you can use the same code above but change all the "6" to "7", I would love to hear your thoughts when you try it!
the new v7 for WP is already available for download on the downloads page if you want to try it, you can use the same code above but change all the "6" to "7", I would love to hear your thoughts when you try it!
This topic is locked and no more replies can be posted.