use a plugin inside another one

use a plugin inside another one

by myur myur -
Number of replies: 4

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: -
In reply to myur myur

Re: use a plugin inside another one

by Daniel Dixon -

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,

In reply to Daniel Dixon

Re: use a plugin inside another one

by myur myur -

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

In reply to Daniel Dixon

Re: use a plugin inside another one

by Olumuyiwa Taiwo -
Picture of Plugin developers

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

In reply to myur myur

Re: use a plugin inside another one

by Olumuyiwa Taiwo -
Picture of Plugin developers

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.