could you provide the code you’re using for your implementation?
Thread Starter
Teja
(@teja8792)
The file (https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/front-end/cmb2-front-end-submit.php) was included(using require_once function) in plugin functions. No changes done to the file. I included CMB2 in plugin-function.php.
Do i have to include CMB2 in cmb2-front-end-submit.php file too?
folder structure.
-plugin-functions.php
-inc/CMB2
-inc/cmb2-front-end-submit.php
Thank You.
As long as CMB2 is loaded already, I am not sure you need to. I’m not sure if you have the plugin version installed and activated, or if you’re treating it as a library you distribute.
From what I know, this is the part you need to include if you’re doing it as a drop in library: https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php#L14
The method giving you a fatal error is in includes/CMB2.php so somehow your code used above is being run before it’s defined and loaded.
Thread Starter
Teja
(@teja8792)
I included the cmb2-front-end-submit.php like this.
if ( file_exists( dirname( __FILE__ ) . ‘/cmb2/init.php’ ) ) {
require_once dirname( __FILE__ ) . ‘/cmb2/init.php’;
} elseif ( file_exists( dirname( __FILE__ ) . ‘/CMB2/init.php’ ) ) {
require_once dirname( __FILE__ ) . ‘/CMB2/init.php’;
}
require_once(‘cmb2-front-end-submit.php’);
I ran into the error again. I am new to the coding, help me out.
Thank you.
Thread Starter
Teja
(@teja8792)
The above code is placed in the plugin-functions.php, I am using the CMB2 folder as library(not downloaded from ww.wp.xz.cn). And i am testing in the localhost.
I’m not familiar with any plugin-functions.php file, as it’s not something from CMB2 and it’s not a standard file name for themes, so I don’t know at all what order things are being loaded in or anything like that.
May be worth trying just installing CMB2 as a plugin instead of as a drop-in library and see if that helps at all. You’d remove the need to manually include CMB2/init.php.
Alternatively, the path in the require_once lines above may not be matching up with your hierarchy, and thus CMB2 isn’t getting loaded properly.
I would be able to easily enough recreate folder structure if you let me know the hierarchy in your case.
Thread Starter
Teja
(@teja8792)
Installed CMB2 as a plugin and it worked. Thanks. How can i use CMB2 as library?
i want to create the custom-plugin and its folder structure is:
custom-plugin(folder)
/custom-plugin.php
/inc(folder)
/inc/CMB2(folder)
/inc/cmb2-front-end-submit.php
Please tell me how to include the CMB2 to avoid the error.
I have another request regarding frontend, do i need to create new topic?
I want to custom taxonomy (category & tags) in frontend. I added new field with taxonomy_select but its not saving the assigned taxonomy.
Thank you.
I wager it’s just a require_once path issue. Take a gander at https://cloudup.com/cMwAagRgs4R. I had it working just fine with that quick setup in the screenshot. Only difference was the inclusion of “/inc” in the specified path.