php WordPress短代码只会向注册用户显示内容。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WordPress短代码只会向注册用户显示内容。相关的知识,希望对你有一定的参考价值。

<?php

/**
 * WordPress shortcode only displays content to registered users.  Could be improved by
 * passing role as an attribute to only allow certain types of users.
 *
 * Example: [member]This text will be only displayed to registered users.[/member]
 */
function members_only_shortcode( $atts, $content = null ) {
    if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
	return $content;
    return '';
}
add_shortcode( 'member', 'members_only_shortcode' );

以上是关于php WordPress短代码只会向注册用户显示内容。的主要内容,如果未能解决你的问题,请参考以下文章

PHP [Wordpress短代码]显示登录用户的内容

php 一个WordPress自定义短代码,用于显示wp_usermeta表中的一段用户元数据。依赖Ultimate Member插件

PHP 在WordPress上显示最近注册的用户

从youtube嵌入缩略图和视频(php - Wordpress)

WordPress 和 Ajax - 重新加载短代码内容

如何在 jQuery( 文档 ).ready 中显示用户名?