Ecommerce Shopify WordPress Discussion

Unable to include login check in custom app inside WordPress directory

I created simple app that fetches product stock and displays it inside table. I need to secure the access to it so only logged in users can see the data. My app resides in subdirectory in wordpress "root/app/index.php". I tried using code below but it always end the same: Even after being logged in, the page doesn't see it and always displays the login form. <?php session_start(); // Include WordPress functions require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-load.php'); require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-login.php'); require_once($_SERVER['DOCUMENT_ROOT'] . '/wp-includes/pluggable.php'); // Check if the user is logged in if (is_user_logged_in()) { // User is logged in, allow access to your app echo "Welcome to my app!"; } else { wp_redirect(wp_login_url()); exit; } ?> Changing the require_once, I also tried this version: global $current_user; get_currentuserinfo(); if ($current_user->ID == '') {
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.