drqrdkfue521903877 2015-11-13 19:34
浏览 52

无法在安装文件夹之外获得wordpress会话用户名

My folder structure:

www.domain.com/myscript.php
www.domain.com/blog/wp-load.php
www.domain.com/blog/bridge.php

Bridge.php:

include('wp-config.php');
include('wp-includes/pluggable.php');
echo $current_user->user_login;

Opening this file manually in my browser correctly output the current logged in username. The problem is that i also need the username in myscript.php which is in the parent folder, outside wordpress install

myscript.php is just:

include("blog/bridge.php");

I have tried everything i could think of: - installed the plugin "root cookie" to enable cookies outside installation dir - if i check firefox cookies, it is correctly set to "/" and not to "/blog" - also the following is set is wp-config.php: define('SITECOOKIEPATH','/'); define('ADMIN_COOKIE_PATH','/'); - tried including different wordpress core files - setting paths including the filesystem root doesn't change anything - including the wordpress files in myscript.php instead of bridge.php doesn't help

  • 写回答

2条回答 默认 最新

  • drjmrg8766 2015-11-13 19:46
    关注

    You actually just need to do this: This will make sure that you can use have access to theme and child them hooks. This will also setup the rest of the environment, including wp-config.php and wp-includes/pluggable.php

    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require ('./wp-blog-header.php');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类