• Hello,

    I’m creating a custom plugin. Poylang is installed and configured in WordPress (both latest version). The plugin uses an own mailer.

    Can’t get the translatiions of the Mailtext working. Following error is thrown:

    Fatal error: Uncaught Error: Call to undefined function pll__() in PATH/TO/PLUGIN/inc/mailing/mailer.php:36 Stack trace: #0

    This is the corresponding line:

    $content = pll__("mailafterregistration");

    The hole code (just trying) of the function is:

    function MailAfterRegistration($userguid) {
     $content = pll__("mailafterregistration");
     $subject = pll__("mailafterregistrationsubject");
     $usermail ) = "[email protected]"
     SendMail($content, $subject, $usermail);
    }
    
    
    function SendMail($content, $subject, $to) {    
     $headers = "MIME-Version: 1.0" . "\r\n"; 
     $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 
     $headers .= 'From: XXXXXXXX' . "\r\n"; 
     $headers .= 'Bcc: XXXXXXX' . "\r\n";  
    
    mail($to, $subject, $content, $headers);
    }

    Can anyone help withj this please? I think I’m missing an include or so?

    Edit: the strings are registered correctly and can be used in other parts of the custom plugin. For example:

    function GetSingleText() {
     $out = '<p>. pll__("mailafterregistration") . '</p>':
     return $out;
    }
    • This topic was modified 1 year, 2 months ago by natfot.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter natfot

    (@natfot)

    Hello,

    I can’t edit my topic anymore (don’t know why).

    I figured out, that pll__(“mailafterregistration”) is not rendered, because it is not used on frondend, only in the mail. So how can i render it outside wordpress to get the translated string?

    Plugin Author Chouby

    (@chouby)

    Hello,

    I am not sure to understand what you mean by “outside WorPress”.

    If the plugins (including Polylang) are correctly loaded in your context, then you must wait for the action plugins_loaded to do anything. Once this action is fired, Polylang will start to initialize and load the api.

    A second condition is that at least one language has been created but I guess it’s the case if you attempt to translated some string.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Fatal error: Uncaught Error: Call to undefined function pll__()’ is closed to new replies.