Jump to content

Shortcode wordpress only shows content for specific user IDs


oc1ober

Recommended Posts

I'm Shortcode wordpress but it doesn't work, the purpose is to show the content to designated members...

For example: in a post or page, Only allow members id1, id7, id25...Visit, And other members cannot view the content, Please edit it for me...

Thank you.

add_shortcode( 'userid', 'check_user_id' );
function check_user_id($atts, $content = null) {
    if(current_user_id) {return '<p>' . $content . '</p>';}
    else {return "";}
}

[userid_logged_in id = "id1","id7","id25","id27"] 
Content displayed
[/userid_logged_in]

 

Edited by oc1ober
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...