Hi @buylov
The best way to just retrieve the amount of a points that an user has earned is using the function gamipress_get_user_points()
This function requires the user ID and the points type slug as parameters
From the shortcode you can just get a formatted output of the user points and to hide the points type plural name you can get it done using CSS to hide them
Best regards
Thread Starter
buylov
(@buylov)
@rubengc
You can give an example of using a function gamipress_get_user_points() with parameters “user ID” and “the points type”?
Hi @buylov
Of course:
gamipress_get_user_points( 1, ‘gems’ );
But this function is to be used from PHP code
I am not sure about what are you looking to do, so to let me provide a more accurated help, Can you explain to me what do you want exactly?
Best regards
Thread Starter
buylov
(@buylov)
hi @rubengc
I need a shortcode that will output only number. Why do not you have this in the plugin?
I used this:
function shortcode_gamipress_points() {
return gamipress_get_user_points(2, ‘myPointType’ );
}
add_shortcode( 'gpoints', 'shortcode_gamipress_points' );
But [gpoints] it outputs 0, although the point are greater than zero.
-
This reply was modified 7 years, 7 months ago by
buylov.
Hi @buylov
There is no sense to add a shortcode to just show a plain number, for the simple reason that shortcodes are intended to be used as a formatted output with some logic
To accomplish your need, you will need to add custom code
Probably you are getting 0 points for some reasons:
1 – The points type slug is wrong
2 – Try to change the characters ‘’ by a common ‘ or ” on the points type slug parameter
3 – Probably the user with ID 2 has no points of the ‘myPointType’ points type
I will mark this as resolved because there is a not issue from GamiPress
Best regards
Thread Starter
buylov
(@buylov)
@rubengc
thanks, it was the reason 2.
You can write more, what are the functions for developers? For example, for ranks. You do not have any information for developers on the site.
Hi @buylov
You are right, the developers docs is something we have pending
First we are focused on get the most common need add-ons ready
Anyway all GamiPress functions and parameters are documented in code so looking at GamiPress files, you will quickly whats inside
Best regards