Created
November 9, 2023 23:59
-
-
Save Lonsdale201/4707959f44a93a363e71347e0bd33123 to your computer and use it in GitHub Desktop.
WooCommerce Points and Rewards get current user point balance shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function hw_current_user_points_shortcode() { | |
| // Csak bejelentkezett felhasználóknál jelenjen meg valami | |
| if ( is_user_logged_in() ) { | |
| $user_id = get_current_user_id(); | |
| // A felhasználó pontegyenlegének lekérdezése a WC_Points_Rewards_Manager osztály használatával | |
| $points = WC_Points_Rewards_Manager::get_users_points( $user_id ); | |
| // Ellenőrizzük, hogy a felhasználónak van-e pontja | |
| if ( empty( $points ) ) { | |
| // Ha nincsenek pontok, adjon vissza egy üzenetet | |
| return 'Még nincs pontod.'; | |
| } else { | |
| // Ha vannak pontok mutasd | |
| return 'Pontjaid: ' . esc_html( $points ); | |
| } | |
| } | |
| return 'Bejelentkezés szükséges a pontok megtekintéséhez.'; | |
| } | |
| add_shortcode( 'current_user_points', 'hw_current_user_points_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment