Hide content for specific users with id

Question

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
mersad ab 4 months 0 Answers 20 views 0

Leave an answer