Call Module Function from Front End I'm looking to call the following Module function from a front end form. I've looked through numerous answers but I can't seem to find a definitive answer on this. 

Here's my Module's code, but obviously I don't want this to run every time and entry get's saved, but when the form on the front-end calls it. 

&lt;?php

namespace modules;

use Craft;

use yii\base\Module;
use yii\base\Event;
use craft\services\Elements;

class ShifterModule extends Module
{
    public function init()
    {

        parent::init();

        Event::on(
            Elements::class,
            Elements::EVENT_AFTER_SAVE_ELEMENT,
            function (ElementEvent $event){
                // Get the correct Entry that's currently saving
                if ($event-&gt;element instanceof craft\elements\Entry) {
                    $entry = $event-&gt;element;
                    // Set $field to the Field Value
                    $field =  $entry-&gt;getFieldValue('proposalStatus');
                    // Set the Proposals &gt; Campaign Authors Email
                    $owner =  $entry-&gt;getFieldValue('proposalCampaign')-&gt;first()-&gt;getAuthor()-&gt;emailAddress;

                    if($field == 'delivered'){
                      return Craft::$app
                          -&gt;getMailer()
                          -&gt;compose()
                          -&gt;setFrom('test@test.com')
                          -&gt;setTo($owner)
                          -&gt;setSubject('Proposal Delivered!')
                          -&gt;send();
                    }
                }
            } // Close Function
        ); // Close Event
    } // Close Public Function
} // Close Module Off
You could use Craft::$app-&gt;getRequest()-&gt;getIsCpRequest() (docs) and do something like this in your innit:

public function init()
{
    parent::init();

    if (!Craft::$app-&gt;getRequest()-&gt;getIsCpRequest()) {
        // Listens for EVENT_AFTER_SAVE_ELEMENT and element instanceof Entry
        self::newEntryElementIsSaved();
    }
}


Then further down add:

protected function newEntryElementIsSaved()
{
    Event::on(
        Elements::class,
        Elements::EVENT_AFTER_SAVE_ELEMENT,
        function (ElementEvent $event){
            // Get the correct Entry that's currently saving
            if ($event-&gt;element instanceof craft\elements\Entry) {
                $entry = $event-&gt;element;
                // Set $field to the Field Value
                $field =  $entry-&gt;getFieldValue('proposalStatus');
                // Set the Proposals &gt; Campaign Authors Email
                $owner =  $entry-&gt;getFieldValue('proposalCampaign')-&gt;first()-&gt;getAuthor()-&gt;emailAddress;

                if($field == 'delivered') {
                  return Craft::$app
                      -&gt;getMailer()
                      -&gt;compose()
                      -&gt;setFrom('test@test.com')
                      -&gt;setTo($owner)
                      -&gt;setSubject('Proposal Delivered!')
                      -&gt;send();
                }
            }
        } // Close Function
    ); // Close Event
}