如何根据登录的用户有不同的Header.php?

时间:2013-01-17 作者:Raghav

我已经使用wishlist成员插件创建了wordpress成员网站。但我想要不同的header.php 基于不同的登录名。

用户包括:打印、网络和免费

免费用户登录时–我想要header1.php 当打印用户登录时,加载并保留直到他注销header2.php 当Web用户登录时,加载并保留直到他注销header3.php 如果没有人登录默认设置,则加载并保留直到他注销header.php 保持不变。

请协助完成此操作。

你好Raghav。

1 个回复
SO网友:fischi

您可以通过获取当前用户的成员级别并基于此设置条件来实现这一点。由于我没有wishlist成员的许可证,这是未经测试的。

我想是吧$member_id 与登录用户的WordPress ID值相同。

<?php 
    global $current_user;
    get_currentuserinfo();
    $member_id = $current_user->ID;
    include(\'wlmapiclass.php\');
    $api = new wlmapiclass(\'http://yourblog.com/\', \'yourAPIKey\');
    $api->return_format = \'php\'; // <- value can also be xml or json
    $membership = $api->get( /members/{$member_id} );
    $membership = unserialize( $membership );
    print_r( $membership ); // see in which value the actual ID or slug of the membership is stored, I cannot reproduce that..
?>
正如TomJNowell指出的,将include改为

get_header( $membershiplevel );
所以你很适合未来的会员级别。

结束

相关推荐

Single.php的分页问题

我在理解世界上最简单的概念时遇到了一些问题,当涉及到构建一个单一的。php文件并使用分页。下面的代码显示了wordpress循环及其内容,最后是分页。然而,分页并没有出现在我面前,看看二十个10主题就知道这就是你应该怎么做的。。。。发生了什么事?这不是自定义循环。<div class=\"span6\"> <?php global $post; $thumb_nail_args = array( \'align\' => \'centere