Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从用户角色类型到页面的php链接_Php_Wordpress_Printf - Fatal编程技术网

从用户角色类型到页面的php链接

从用户角色类型到页面的php链接,php,wordpress,printf,Php,Wordpress,Printf,我试图为用户创建一个链接,以便在显示他们所属的组时导航到: <?php $user = wp_get_current_user();?> <a href="#"><?php printf( '%s.', $user->roles[0] );?></a> 代码很好地反映了用户所属的角色(组),现在我只需要它是指向相应页面的链接(与用户角色同名) e、 g“您在Alpha组”(其中Alpha需要是指向Alpha页面的链接) 有人能帮忙吗?h

我试图为用户创建一个链接,以便在显示他们所属的组时导航到:

<?php $user = wp_get_current_user();?>
<a href="#"><?php printf( '%s.', $user->roles[0] );?></a>

代码很好地反映了用户所属的角色(组),现在我只需要它是指向相应页面的链接(与用户角色同名)

e、 g“您在Alpha组”(其中Alpha需要是指向Alpha页面的链接)

有人能帮忙吗?

href=“#”
是您需要更改的内容

例如:

    <?php $user = wp_get_current_user();?>
    <a href="http://example.com/<php echo $user->roles[0];?>"><?php printf( '%s.', $user->roles[0] );?></a>
甚至:

    <?php $user = wp_get_current_user();?>
    <a href="http://example.com/<?php printf($user->roles[0]);?>"><?php printf( '%s.', $user->roles[0] );?></a>

但是在你的情况下,
echo
就足够了



请注意,这是一个关于<代码> HTML<代码>的基本知识,在< PHP编程之前,你应该首先考虑学习。

谢谢,这正是我所需要的。我知道HTML和非常简单的php,我需要你给我写href=“example.com/roles[0];?>”,所以很好。非常感谢:-)请将其标记为答案,这样它就不会在答案分数(答案左上方)下的列表中显示为未回答。您得到了“a”✔️" 您需要单击
    <?php $user = wp_get_current_user();?>
    <a href="http://example.com/<?php printf($user->roles[0]);?>"><?php printf( '%s.', $user->roles[0] );?></a>