Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author myCred

    (@designbymerovingi)

    Hi.

    Right now the setup you do on myCRED the first time you install the plugin is what is used. So if you setup myCRED to use decimals you can not change it to no decimals later.

    In case you can not re-install or do not feel comfortable with adjusting SQL tables on your own, the easiest solution would be to filter how points are displayed by always displaying points without decimals.

    This is done via the mycred_format_creds filter which fires just before points are displayed. Here is a quick example of how you can remove decimals:

    add_filter( 'mycred_format_creds', 'remove_mycred_decimals' );
    function remove_mycred_decimals( $amount ) {
    	return number_format( (int) $amount, 0, '.', '' );
    }
    Thread Starter maddogmcewan

    (@maddogmcewan)

    aaaah – no worries – in which table is that stored – i can edit in db

    Plugin Author myCred

    (@designbymerovingi)

    There are two things you would need to change:

    1. You would need to change the myCRED_log table ( prefix_myCRED_log ) and you would need to change the core settings to stop showing decimals. The myCRED core settings are stored in the options table under the key: mycred_pref_core. It contains an associative array of settings and under “format” you will see “decimals” having a value of 2. Change this to zero.

    In 1.5 I am working on adding the option to change this via a button but right now unfortunately your setup is enforced.

    Thread Starter maddogmcewan

    (@maddogmcewan)

    thanx for that – done !!!! my log table was empty though

    fresh-x

    (@fresh-x)

    hey, i also now wanted to cut the value after the point, just like that from 100.00 to 100 points, so with a little jquery script u also can do this – works well, by display points inside a <span class=”one”>…</span>

    var points = Math.round($("span.one").text());
    $("span.one").html(points);

    maybe is useful for some others, they may also dont want to change core things in plugin.

    Plugin Author myCred

    (@designbymerovingi)

    @fresh-x thanks for the suggestion. I do recommend that if you want to remove decimals you use the mycred_format_creds filter which myCRED provides:

    Basic example:

    add_filter( 'mycred_format_creds', 'mycred_pro_remove_decimals' );
    function mycred_pro_remove_decimals( $amount ) { return (int) $amount; }

    The above code goes into your theme’s functions.php file and will be applied to all point types.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Decimals’ is closed to new replies.