General developer forum

use a plugin inside another one

 
Picture of myur myur
use a plugin inside another one
 

Hi!

I'm new on moodle and I need to use plugins, as poll, questionary or chat, inside a plugin I'm working on. But not just like be "available" like a menu, but to display and do a poll into a page of my plugin. So, how can I "call" an existing plugin on moodle inside the code of my page or form.


Thank you smile

 
Average of ratings: -
Picture of Daniel Dixon
Re: use a plugin inside another one
 

Hello Mayur,

Try this out, it's commented, so that should help you understand it.

<?php
register_activation_hook( __FILE__, 'myplugin_activate' ); // Register myplugin_activate on
function myplugin_activate() {
    $plugin = plugin_basename( __FILE__ ); // 'myplugin'
    if ( is_plugin_active( 'plugin-directory/first-plugin.php' ) ) {
        // Plugin was active, do hook for 'myplugin'
    } else {
        // Plugin was not-active, uh oh, do not allow this plugin to activate
        deactivate_plugins( $plugin ); // Deactivate 'myplugin'
    }
}
?> 
If this throws out an error, you could also check the 'option' of 'myplugin' and set it to false or not activated.


Regards,

Techtiq Solutions,

 
Average of ratings: -
Picture of myur myur
Re: use a plugin inside another one
 

Hi!


thak you for your response.


Well I had an error, but it is:


"Call to undefined function register_activation_hook()"


do you know wich file manage the function to call it into my php file?


thank you

 
Average of ratings: -
Picture of Olumuyiwa Taiwo
Re: use a plugin inside another one
Particularly helpful Moodlers

Looks like you landed on the wrong forum -- this is the Moodle forum, not WordPress smile

 
Average of ratings: -
Picture of Olumuyiwa Taiwo
Re: use a plugin inside another one
Particularly helpful Moodlers

A crude way might be to display the plugin inside an iFrame on your plugin's page?

Before you go down that route though, you might want to go over the reason's why you want to do what you describe, otherwise you may be putting yourself through a lot of unnecessary pain.

 
Average of ratings: -