Craft 3 Plugin not returning custom field value I am trying to get the value of a custom field in entries, but I can't seem to get it to grab that value. I'm assuming I'm pulling it too early or too late, otherwise I have no idea.

I can pull the value the of the lightswitch enabled

Event::on(Elements::class, Elements::EVENT_AFTER_SAVE_ELEMENT, function(Event $event) 
    {
        $request = Craft::$app-&gt;getRequest();

        // will successfully send email if enabled lightswitch is on
        if($request-&gt;getBodyParam('enabled') == 1)
        {
            $html = $request-&gt;getBodyParam('enabled');
            $subject = "testing";
            $mail = "example@gmail.com";
            return $this-&gt;sendMail($html, $subject, $mail);
        }
    });


The below doesn't return anything at all for the custom field fields[sendEmail]

Event::on(Elements::class, Elements::EVENT_AFTER_SAVE_ELEMENT, function(Event $event) 
    {
        $request = Craft::$app-&gt;getRequest();

        // will not send email no matter what position the lightswitch is in
        if($request-&gt;getBodyParam('fields[sendEmail]') == 1)
        {
            $html = $request-&gt;getBodyParam('fields[sendEmail]');
            $subject = "testing";
            $mail = "example@gmail.com";
            return $this-&gt;sendMail($html, $subject, $mail);
        }
    });


I tried changing the event handler to EVENT_BEFORE_SAVE_ELEMENT but it made no difference.
Found my answer here

// get $_POST['foo']['bar'], if it exists
$bar = Craft::$app-&gt;request-&gt;getBodyParam('foo.bar');


or inserting it into my code

Event::on(Elements::class, Elements::EVENT_AFTER_SAVE_ELEMENT, function(Event $event) 
{
    $request = Craft::$app-&gt;getRequest();

    if($request-&gt;getBodyParam('fields.sendEmail') == 1)
    {
        $html = $request-&gt;getBodyParam('fields.sendEmail');
        $subject = "testing";
        $mail = "example@gmail.com";
        $this-&gt;sendMail($html, $subject, $mail);
    }
});