php - WP is_user_logged_in() doesn't work in integrated site -
i trying integrate wp functions in external php file.
the problem user's , login's authentication functions is_user_logged_in(), is_admin(), etc doesn't work @ all. however, post's functions working correct. so, has "session" problem.
actually after deep deep search, "good" post in web issue following old post in wp support: https://wordpress.org/support/topic/how-to-integrate-sessionlogin-authentication-to-non-wordpress-pages-w-wp-auth
but, solution isn't working @ all, , if enable root cookie plugin, can not login /wp-blog/
so, there idea how integrate , login functions in php file?
code pretty simple:
file.php
<?php //define('wp_use_themes', false); //include($_server['document_root'].'/wp-blog/wp-load.php'); include($_server['document_root'].'/wp-blog/wp-blog-header.php'); if ( is_user_logged_in() ) { echo 'logged in.'; } else { echo 'not logged in.'; } ?> also, have following warning in error logs
php warning: session_start(): cannot send session cache limiter - headers sent (output started @ /..../) in /....../wp-content/plugins/global-content-blocks/global-content-blocks.php on line 302
edit:
i add function.php rnevius said in comments
code:
include($_server['document_root'].'/wp-blog/wp-blog-header.php'); include($_server['document_root'].'/wp-blog/wp-includes/functions.php'); and have
the following fatal warning , fatal error:
php warning: session_start(): cannot send session cache limiter - headers sent (output started @ /..../) in /....../wp-content/plugins/global-content-blocks/global-content-blocks.php on line 302
php fatal error: cannot redeclare mysql2date() (previously declared in /...../wp-includes/functions.php:26) in /....../wp-includes/functions.php on line 42
edit:
also, have tried following:
define('wp_use_themes', false); //include($_server['document_root'].'/wp-blog/wp-load.php'); include($_server['document_root'].'/wp-blog/wp-blog-header.php'); and
define('wp_use_themes', false); include($_server['document_root'].'/wp-blog/wp-load.php'); //include($_server['document_root'].'/wp-blog/wp-blog-header.php'); edit:
this may think ideas:
we have following structure:
domain.com/test/ domain.com/wp-blog/ domain.com/wp-blog/test/ if file file.php if in /test/ doesn't work.
domain.com/test/file.php domain.com/wp-blog/ domain.com/wp-blog/test/ if file file.php in /wp-blog/ works!!
domain.com/test/ domain.com/wp-blog/file.php domain.com/wp-blog/test/ if file file.php in /wp-blog/test/ works!!
domain.com/test/ domain.com/wp-blog/ domain.com/wp-blog/test/file.php every folder on "domain" has 755 , files 644 permissions. not "permission" problem. other thoughts?
you're missing variable stops loading output:
//load startup define('wp_use_themes', false); require_once( $_server[ "document_root" ] . "/wp-blog-header.php" );
Comments
Post a Comment