dongyu1983 2015-01-16 16:10
浏览 41

PHP - 无法打印真正基本的东西

I'm working on my website and I'm having some trouble with PHP syntax. I just want to say "Welcome, [name]" when users are logged in. I'm working on Wordpress and I'm using a plugin to work with users. So, as I want to align the text on the right side of the website, I have this:

print"<p align=\"RIGHT\">Welcome, </p>";

But now I need to insert the name. For doing that I have a shortcode:

[user-data field_name="Name"]

I'm trying to put those things together, but is not working. I'm using do_shortcode, but I don't know how to put that together.

do_shortcode('[user-data field_name="Nombre"]')

Hope someone can help me. thank you very much!

  • 写回答

1条回答 默认 最新

  • doujizhong8352 2015-01-16 16:24
    关注

    if the plugin is querying the databse table _users you should be able to store the name of the current user in a variable and then add that to your output. I'm not sure what plugin you're using, but try something like this. This is how I've always done it.

    <?php if(is_user_logged_in()) : ?>
        <?php
            global $current_user;
            get_currentuserinfo();
            $username = $current_user->user_login;
         ?>
        <p class="your-class">Welcome, <?php echo $username; ?></p>
    <?php endif; ?>
    

    if that doesn't work I would hop into your database and find the table/field where the usernames are being stored and then call/store them in a similar manner

    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数