Executing function in child best practices

Hey there!

I’m creating an extension for the dashboard that will need to execute a specific function on the child sites, so I’m wondering what are the best practices of doing it without using the Snippets extension, for example.

I was thinking of creating a child extension to be installed on the child sites that would receive the request and execute the function. I found the $callableFunctions array on the class-mainwp-child-callable.php file, but it has no filters to add new entries, so I’m not really sure how to add my own callable function, or what step I should take.

Any hints are appreciated.


Hi Lucio,

Thanks for reaching out. I am happy to see MainWP users using one of the biggest advantages of the MainWP system which is flexibility for custom features.

Have you checked the mainwp_child_extra_execution filter in the class-mainwp-child-callable.php` file?

	 * Method extra_execution()
	 * Additional functions to execute.
	 * @uses \MainWP\Child\MainWP_Helper::write()
	public function extra_execution() {
		$post        = $_POST;
		$information = array();
		 * Filter 'mainwp_child_extra_execution'
		 * Additional functions to execute through the filter.
		 * @param array $information An array containing the synchronization information.
		 * @param mixed $post Contains the POST request.
		 * @since 4.0
		$information = apply_filters( 'mainwp_child_extra_execution', $information, $post );
		MainWP_Helper::write( $information );

I believe that this will help you accomplish what you need.


Omg, I can’t believe I missed that one!

Thank you very much @bogdan! It will definitely work :slight_smile:


You are welcome! I am glad I could help.

However, I am super curious to know more about your custom extension :slight_smile:
If you feel like it, please share a few details :smiley:


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.