最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Hide content for specific users with id

programmeradmin5浏览0评论

I want to write a short code so that users who write their id's in it can not see the content of the short code! Example:

[hidefrom ids="1,46"]content[/hidefrom]

Please help me, I do not know anything about php!

function hidefrom_func($atts, $content = null) {
  global $current_user, $user_login;
  
  if ($user_login)
  extract(shortcode_atts(array('ids' => '1' ), $atts));
  
  $a = wp_get_current_user();
  
  if($a->ID == $ids){

    echo 'access denied!';

  } else {

    return ($content);

  }
}

add_shortcode('hidefrom', 'hidefrom_func');

发布评论

评论列表(0)

  1. 暂无评论