Ecommerce Shopify WordPress Discussion

Struggle to get get_current_user_id() in wordpress [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 8 days ago. Improve this question enter image description here I am trying to get the user ID of the currently logged in user when save the coupon data to database. However, i am getting user id = 0. my error_log also shows that user is not logged in. I am making my own plugin and the code snipper is in my plugin's main php file. I am also using Astra Theme and Ultimate Member plguin Clear cookies and cache data
You can try this code to get current user: global $current_user; $user_id = $current_user->ID; or global $current_user; $user_id = get_current_user_id(); Or use this WordPress function $current_user = wp_get_current_user(); $current_user_id = $current_user->ID;

December 30, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.