Get User Points for a period time
-
Hi, I get the total points of a user with this code:
from this doc: https://gamipress.com/snippets/custom-functionalities/gamipress_sum_of_points-shortcode/function my_prefix_gamipress_sum_of_points_shortcode( $atts ) { $atts = shortcode_atts( array( 'points_type' => 'all', 'user_id' => '0', 'current_user' => 'no' ), $atts, 'gamipress_sum_of_points' ); // Check desired points types if( $atts['points_type'] === 'all') { $points_types = gamipress_get_points_types_slugs(); } else { $points_types = explode( ',', $atts['points_type'] ); } // Force to set current user as user ID if( $atts['current_user'] === 'yes' ) { $atts['user_id'] = get_current_user_id(); } else if( absint( $atts['user_id'] ) === 0 ) { $atts['user_id'] = get_current_user_id(); } $sum_of_points = 0; foreach( $points_types as $points_type ) { // Ensure that this points type slug is registered if( ! in_array( $points_type, gamipress_get_points_types_slugs() ) ) { continue; } $sum_of_points += gamipress_get_user_points( $atts['user_id'], $points_type ); } // Return the sum of points of all or specific points types return $sum_of_points; } add_shortcode( 'gamipress_sum_of_points', 'my_prefix_gamipress_sum_of_points_shortcode' );
How i can impact time period in this code? for example get the last 7 days points that user awards.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get User Points for a period time’ is closed to new replies.