CodeIgniter Forums
Getting CI instance in Wordpress functions.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Getting CI instance in Wordpress functions.php (/showthread.php?tid=76283)



Getting CI instance in Wordpress functions.php - bargoldi - 04-29-2020

Hi guys,
I have an old project that contains:
a. A CI Folder with project and views inside of it
b. A Wordpress project that contains the CI views as iframes. My job is to take it from the old WP site to Elementor and stuff.

The CI also manages my user authentication and details.

What I'm trying to do on my WP project is:
Changing a button text based on whether the user is logged on or not.
It worked perfectly in the old version using this code:
/* @var $CI \MY_Controller */
$CI =& get_instance();
if ($CI->user->isMember()): etc....


Now I'm trying to create an Elementor Dynamic tag for that inside functions.php
I'm using the same code but I get:  Uncaught Error: Call to undefined function get_instance() 

Not sure what I'm missing but it seems like the WP is not connected to the CI or something and I can't find the point it's connected on the old project.

Thanks a lot guys for your help!


RE: Getting CI instance in Wordpress functions.php - bargoldi - 04-30-2020

Adding a pastebin:
https://pastebin.com/5M65EUCm