如何判断WordPress登录用户的角色
具体实现步骤如下:1、将以下代码添加到Three主题的functions.php文件最后一个?>的前面。
//部分内容登录可见function login_to_read($atts, $content=null) {extract(shortcode_atts(array("notice" =>'温馨提示:此处内容需要登录后才能查看!'), $atts));if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )return $content;return $notice;}add_shortcode('vip', 'login_to_read');PS:将上面代码中的login.php替换为站点的登录地址,以方便用户快速登录。
2、在编辑文章的时候,只需要切换到文本模式,在需要隐藏的部分内容中前后加上短代码即可。
[vip]我是被隐藏的内容,样式一(默认样式)[/vip][vip notice="登录后才显示哟"]我是被隐藏的内容,样式二(自定义回复信息)[/vip]其中样式一的提示信息就是第一步中的“温馨提示:此处内容需要登录后才能查看!”,样式二的提示信息就是“登录后才显示哟”,具体选用哪个样式由大家自己决定了。
WordPress如何设置先登录再进入主页
写个自定义函数然后调用就可以了,很简单。
1. 添加自定义函数,找到当前主题的function.php,并在这个文件中添加如下函数function login_if_not(){if(!is_user_logged_in()){auth_redirect();}}2.调用自定义函数,在当前主题的header.php中添加如下代码:这样就可以满足你的需求。
如果有效,请采纳,谢谢
wordpress站内公告工具怎么用
把这个代码放入你主题的functions.php 中,不过在这里建议大家最好是放在另一个文件中,这样以后比较好查找和修改。
还有一点就是函数命名要唯一,不然会和其他函数命名一样而报错。
也可以加上if ( !function_exists('my_test') ) {} 来判断是否存在这个方法,如果存在将不会运行。
这样可以避免报错!如下:if(is_user_logged_in()){$current_user = wp_get_current_user();/*** @example Safe usage: $current_user = wp_get_current_user();* if ( !($current_user instanceof WP_User) )* return;*/echo 'Username: ' . $current_user->user_login . '';echo 'User email: ' . $current_user->user_email . '';echo 'User first name: ' . $current_user->user_firstname . '';echo 'User last name: ' . $current_user->user_lastname . '';echo 'User display name: ' . $current_user->display_name . '';echo 'User ID: ' . $current_user->ID . '';}
wordpress后台登陆地址,怎么进入WordPress后台
一。
研究wordpress时wordpess的密码密码生成与登录密码验证方式很重要 WordPress密码已成为整合的首要目标,如何征服整合,就得了解WordPress密码算法。
WordPress系统的用户密码是保存在wp_users数据表的user_pass字段,密码是通过Portable PHP password hashing framework类产生的,密码的形式是随机且不可逆,同一个明文的密码在不同时间,产生的密文也不一样,相对来说较为安全。
二。
密码生成方式> 随机产生一个salt 并将salt和password相加> 进行了count次md5 然后和encode64的hash数值累加> 最后得到一个以$P$开头的密码,这个密码每次产生的结果都不一样 以下为在wordpress中调用密码生成的代码 [php] view plain copy print?$password = 'abc'; global $wp_hasher; if ( empty($wp_hasher) ) { require_once( './wp-includes/class-phpass.php'); $wp_hasher = new PasswordHash(8, TRUE); } echo $wp_hasher->HashPassword($password); ?> 三。
wordpress密码生成与登录验证 wordpress中位置为\wp-includes\class-phpass.php 以下是wordpress中生成密码的代码直接运行可查看密码的生成以及验证过程 [php] view plain copy print?class PasswordHash { var $itoa64; var $iteration_count_log2; var $portable_hashes; var $random_state; function PasswordHash($iteration_count_log2, $portable_hashes) { $this->itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; if ($iteration_count_log2 4 || $iteration_count_log2 > 31) $iteration_count_log2 = 8; $this->iteration_count_log2 = $iteration_count_log2; $this->portable_hashes = $portable_hashes; $this->random_state = microtime() . uniqid(rand(), TRUE); // removed getmypid() for compability reasons } function get_random_bytes($count) { $output = ''; if ( @is_readable('/dev/urandom') && ($fh = @fopen('/dev/urandom', 'rb'))) { $output = fread($fh, $count); fclose($fh); } if (strlen($output) $output = ''; for ($i = 0; $i $this->random_state = md5(microtime() . $this->random_state); $output .= pack('H*', md5($this->random_state)); } $output = substr($output, 0, $count); } return $output; } function encode64($input, $count) { $output = ''; $i = 0; do { $value = ord($input[$i++]); $output .= $this->itoa64[$value & 0x3f]; if ($i $value |= ord($input[$i]) $output .= $this->itoa64[($value >> 6) & 0x3f]; if ($i++ >= $count) break; if ($i $value |= ord($input[$i]) $output .= $this->itoa64[($value >> 12) & 0x3f]; if ($i++ >= $count) break; $output .= $this->itoa64[($value >> 18) & 0x3f]; } while ($i return $output; } function gensalt_private($input) { $output = '$PXXXXX; $output .= $this->itoa64[min($this->iteration_count_log2 + ((PHP_VERSION >= '5') ? 5 : 3), 30)]; $output .= $this->encode64($input, 6); return $output; } function crypt_private($password, $setting) { $output = '*0'; if (substr($setting, 0, 2) == $output) $output = '*1'; $id = substr($setting, 0, 3); # We use "$P{1}quot;, phpBB3 uses "$H{1}quot; for the same thing if ($id != '$PXXXXX && $id != '$HXXXXX) return $output; $count_log2 = strpos($this->itoa64, $setting[3]); if ($count_log2 7 || $count_log2 > 30) return $output; $count = 1 $salt = substr($setting, 4, 8); if (strlen($salt) != 8) return $output; # We're kind of forced to use MD5 here since it's the only # cryptographic primitive available in all versions of PHP # currently in use. To implement our own low-level crypto # in PHP would result in much worse performance and # consequently in lower iteration counts and hashes that are # quicker to crack (by non-PHP code). if (PHP_VERSION >= '5') { $hash = md5($salt . $password, TRUE); do { $hash = md5($hash . $password, TRUE); } while (--$count); } else { $hash = pack('H*', md5($salt . $password)); do { $hash = pack('H*', md5($hash . $password)); } while (--$count); } $output = substr($setting, 0, 12); $output .= $this->encode64($hash, 16); return $output; } function gensalt_extended($input) { $count_log2 = min($this->iteration_count_log2 + 8, 24); # This should be odd to not reveal weak DES keys, and the # maximum valid value is (2**24 - 1) which is odd anyway. $count = (1 $output = '_'; $output .= $this->itoa64[$count & 0x3f]; $output .= $this->itoa64[($count >> 6) & 0x3f]; $output .= $this->itoa64[($count >> 12) & 0x3f]; $output .= $this->itoa64[($count >> 18) & 0x3f]; $output .= $this->encode64($input, 3); return $output; } function gensalt_blowfish($input) { # This one needs to use a different order of characters and a # different encoding scheme from the one in encode64() above. # We care because the last character in our encoded string will # only represent 2 bits. While two known implementations of # bcrypt will happily accept and correct a salt string which # has the 4 unused bits set to non-zero, we do not want to take # ...
WordPress中的分类目录找不到怎么解决?
wordpress中添加了分类目录,菜单里面的分类目录不显示的原因:没有添加文章。
添加一篇文章即可。
WordPress网站在菜单里添加分类目录的方法:1. wordpress是制作网站的一种工具,首先要有自己的wordpress。
然后进入的wordpress选择文章下的分类目录选项。
2. 点击下面的“添加新分类目录”。
3. 然后选择“外观”里的“菜单”,这个菜单就是以后网站上面横条显示目录的地方。
4. 然后看到左下角。
分类目录 里,点击查看所有会看到所有以前添加过的目录都在里面。
此时选择 “诗歌” 然后选择“添加至菜单”诗歌目录就进入了菜单里面了。
5. 登陆自己的网站,看登陆看效果,而且排在最后一个,想排在前面,在菜单那里是可以改顺序的。
进去就能看到。
wordpress 后台导航菜单自定义class,为什么前台无显示
wordpress 导航菜单的调用,一般都使用自带的wp_nav_menu()函数,使用后发现,这个函数并没提供给我们给每一项导航菜单添加自定义class的接口功能!搜索了下,最终在老外的一篇文章中发现了wordpress自身提供的解决方法!嗯,wordpress还是很强大的...方法很简单:依次进入wordpress后台->外观->菜单,然后在页面右侧的右上角点“显示选项”,我们看到“显示菜单高级属性”中有个“css类”选项,把它选中,再看菜单项中,已多出一个css类输入框,该框输入的内容即为导航菜单项自定义的class值!!再次见识到了wordpress的强大,擅抖吧,骚年!!哈...
转载请注明出处51数据库 » wordpress is_user_lo