WordPress.org

Ready to get started?Download WordPress

Forums

Paid Memberships Pro
Change language with pmpro_levels (9 posts)

  1. marvmckay66
    Member
    Posted 11 months ago #

    On my registration page, the text output is "The price for membership is $3.95 now. Membership expires after 1 month."

    How can I change that language? I would rather have it say something like "A one month membership is $3.95." I think the "now" is awkward, as it suggests that it's going to change.

    https://wordpress.org/plugins/paid-memberships-pro/

  2. messica
    Member
    Plugin Author

    Posted 11 months ago #

    You can change the text by using the pmpro_level_cost_text filter. An example can be found here: https://gist.github.com/strangerstudios/8150762#file-nicer_pmpro_level_cost_text-php-L4-L15

    Hope that helps!

  3. James
    Member
    Posted 11 months ago #

    Hello Jessica,

    Basically, have the same question.

    These lines are from pmpro_getLevelCost(). All are in .po file, but they are not translatable, at least these 3 lines, which includes "The price for membership is..." - changes in .po have no effect in the front-end.

    Do you mean that this text cannot be translated from .po, what the point of adding it?

    thanks!

  4. marvmckay66
    Member
    Posted 11 months ago #

    I added the "Nicer level costs example" code to my theme's functions.php file as directed, but it didn't affect the text output at all ... it still reads "The price for membership is $3.95 now. Membership expires after 1 month."

    Very strange that it had no effect - the code looks pretty straightforward.

  5. Great H-master
    Member
    Plugin Author

    Posted 11 months ago #

    Hello.

    @James
    Has the wp-config.php file been updated to support the language? Also, have you compiled the .mo file? PMPro reads the .mo for to do the translations.

    @marvmckay66
    Very odd, try adding die("here"); to the code to see if it is actually getting to your code. Another bit of code could be undoing the changes. In which case try changing the priority of the filter.

    Hope this helps.

  6. marvmckay66
    Member
    Posted 11 months ago #

    Here's something odd - I had already tried testing by commenting out the $text line and adding my own, which you'll see below. Then I added your die("here"); line above - this is what the code looks like, but scroll down to see what actually happened:

    function nicer_pmpro_level_cost_text($text, $level)
    {
    global $pmpro_currency_symbol;

    if(pmpro_isLevelFree($level))
    $text = "Membership is free.";
    elseif($level->initial_payment == $level->billing_amount)
    die("here");
    //$text = $pmpro_currency_symbol . $level->initial_payment . "/" . $level->cycle_period;
    $text = "hello";
    return $text;
    }
    add_filter("pmpro_level_cost_text", "nicer_pmpro_level_cost_text", 15, 2);

    When I uploaded this, it skipped over "die" and you'll see the next line is commented out, but then it output the "hello." So then I got rid of "hello" and "die" and uncommented the original text line, and it still said "The price for membership is $3.95 now. Membership expires after 1 Month."

  7. marvmckay66
    Member
    Posted 11 months ago #

    Here's something weird - the "die" line seems to help the next line; I just tried using this:

    elseif($level->initial_payment == $level->billing_amount)
    die("here");
    $text = $pmpro_currency_symbol . $level->initial_payment . "/" . $level->cycle_period;
    return $text;

    And it outputs "$3.95/ "

    So the die is helping, but not all the way, it's not recognizing the cycle period.

  8. James
    Member
    Posted 11 months ago #

    hi! it's not about .mo + other strings work fine.

    Probably, issue is that you are using _x, which is not working well with all editors. Had to read multiple threads, add additional translation keywords, but I still cannot get these lines working from Poedit.

    Maybe you could try to test some translation yourself. As a whole, it looks like these _x are not necessary at all. Idea is to comment 100% equal lines, but in Pmpro functions.php, where I see all these _x, most lines are different and you are using _x as a simple comment option - this is just my opinion of course.

    thanks!

  9. messica
    Member
    Plugin Author

    Posted 11 months ago #

    You need to remove the die('here'); for the code to continue running. It should like this:

    function nicer_pmpro_level_cost_text($text, $level)
    {
        global $pmpro_currency_symbol;
    
        if(pmpro_isLevelFree($level))
            $text = "Membership is free.";
        elseif($level->initial_payment == $level->billing_amount)
            $text = $pmpro_currency_symbol . $level->initial_payment . "/" . $level->cycle_period;
        return $text;
    }
    add_filter("pmpro_level_cost_text", "nicer_pmpro_level_cost_text", 15, 2);

Reply

You must log in to post.

About this Plugin

About this Topic