• Resolved Martin Braun

    (@martinbraun)


    Hi,

    I’m working on a plugin for TNP that brings more flexible ways to subscribe to the newsletter system. In that stage, I also use Polylang to localize my website. TNP supports Polylang, since I can localize all the emails (i.e. welcome email, etc.), but it does not seem to work for the API. Since I don’t use the newsletter form of TNP, I rely on the API to be able to get or take the relevant information what language the user prefers.

    Here is some example code to illustrate the problem:

    $email = "[email protected]";
    $name = "Foo Bar";
    $result = TNP::subscribe([
    	'email' => $email,
    	'name' => $name,
    	'status' => ''
    ]);
    if (is_wp_error($result))
    {
    	error_log($result->get_error_message());
    }

    This code will add the subscription. TNP::subscribe() will not take any language argument, so I cannot enforce any localization. In result, the user will get the default english welcome email.

    The API should be complete by allowing me to provide a language parameter. Can this be implemented in the next update? How can I bypass this issue now?

    The second issue is that error messages aren’t localized either. So if you re-run this code after the user has been subscribed, this will log “Email address already exists” to the debug.log.

    If the API would take an argument for the language and localize error messages that can be displayed to the user, this would be great.

    • This topic was modified 6 years, 3 months ago by Martin Braun.
    • This topic was modified 6 years, 3 months ago by Martin Braun.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Stefano Lissa

    (@satollo)

    I need to update the API so you can send even the “language” attribute.

    Stefano.

    Thread Starter Martin Braun

    (@martinbraun)

    Hi @satollo,

    thank you for the quick reply. So you are planning to add the “language” attribute? If you decide to go for it in the future and will use the attribute name “language”, I will set it in my plugin for now and hope for it to solve itself.

    Thank you for the great plugin.

    Best regards,

    Martin

    Plugin Author Stefano Lissa

    (@satollo)

    Yes, sorry, on next release (probably Monday).

    Stefano.

    Thread Starter Martin Braun

    (@martinbraun)

    Thank you so much! 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Subscribe-API and localization with Polylang’ is closed to new replies.