博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
wordpress页面_强制登录以查看WordPress博客页面
阅读量:2519 次
发布时间:2019-05-11

本文共 1256 字,大约阅读时间需要 4 分钟。

wordpress页面

I was recently working on a private / "closed" website that featured WordPress.  User management is a must and content can only be seen if the user is logged in.  I was shocked to find that WordPress didn't provide an option to accomplish this task.  Luckily a quick snippet in the header of my template allowed me to force login to view content:

我最近在一个以WordPress为特色的私人/“封闭”网站上工作。 用户管理是必须的,只有在用户登录后才能看到内容。震惊地发现WordPress没有提供完成此任务的选项。 幸运的是,模板标题中有一个简短的摘要,使我可以强制登录以查看内容:

// Require login for siteget_currentuserinfo();global $user_ID;if ($user_ID == '') { 	header('Location: /wp-login.php'); exit(); }

The get_currentuserinfo() function provides a huge object with information about the user.  We then look at the user_ID variable to see if the user's ID is defined -- if not, they aren't logged in and we should send them to the login page!

get_currentuserinfo()函数提供了一个巨大的对象,其中包含有关用户的信息。 然后,我们查看user_ID变量以查看是否定义了用户的ID-如果未定义,则他们没有登录,我们应该将其发送到登录页面!

Do remember that your header() calls must take place before any content is pushed to the page, so I recommend adding this content at the very top of your header.php file. There's also a to accomplish this task.

请记住,您的header()调用必须在将任何内容推送到页面之前进行,因此我建议将此内容添加到header.php文件的最顶部。 还有一个可以完成此任务。

翻译自:

wordpress页面

转载地址:http://bcpwd.baihongyu.com/

你可能感兴趣的文章
将PHP数组输出为HTML表格
查看>>
Java中的线程Thread方法之---suspend()和resume() 分类: ...
查看>>
经典排序算法回顾:选择排序,快速排序
查看>>
BZOJ2213 [Poi2011]Difference 【乱搞】
查看>>
c# 对加密的MP4文件进行解密
查看>>
AOP面向切面编程C#实例
查看>>
AngularJs学习笔记-慕课网AngularJS实战
查看>>
数据库三大范式
查看>>
工作总结之二:bug级别、优先级别、bug状态
查看>>
访问修饰符、封装、继承
查看>>
更换pip源到国内镜像,提升pip下载速度.
查看>>
POJ 2265 Bee Maja (找规律)
查看>>
Kendo MVVM 数据绑定(七) Invisible/Visible
查看>>
[zz]kvm环境使用libvirt创建虚拟机
查看>>
bzoj1059 [ZJOI2007]矩阵游戏
查看>>
插入返回ibatis 的selectKey 实现插入数据后获得id
查看>>
vim 程序编辑器
查看>>
LIS(单调队列优化 C++ 版)(施工ing)
查看>>
刚接触Vuex
查看>>
四种加载React数据的技术对比(Meteor 转)
查看>>