java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

wordpress cookie给第三方程序使用

wordpress 的内部用户变量

user_login . "\n";
 echo '用户邮箱: ' . $current_user->user_email . "\n";
 echo '名字: ' . $current_user->user_firstname . "\n";
 echo '姓氏: ' . $current_user->user_lastname . "\n";
 echo '公开显示名: ' . $current_user->display_name . "\n";
 echo '用户 ID:' . $current_user->ID . "\n";
?>

自己为wordpress写个新cookie给第三方程序使用
在模板的functions.php增加一个函数

//add new cookie
function set_newuser_cookie() {
	global $current_user;
	 get_currentuserinfo();
	 $username = $current_user->user_login;
	 $nicename = $current_user->user_nicename;
	if (!isset($_COOKIE['java_cookie'])) {
		setcookie('j_username', $username, time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false);
		setcookie('j_nicename', $nicename, time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false);
	}
}

在模板的functions.php增加一句话

add_action('after_setup_theme', 'set_newuser_cookie');


This entry was posted in PHP. Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/wordpress-cookie-third-program-use/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply