I want to create a shortcode with conditions based on who the current user is
I have the essence of my shortcode…
function my_shortcode_function() {
return 'here is the content of my shortcode!';
}
add_shortcode('coolshortcodename', 'my_shortcode_function');
But I need to add conditions to it…I want to say if user ID is Jonny then show this, if the user is Sally show that, if the user is Jamie something else…
function my_shortcode_function() {
IF JONNY
return reblex_display_block(610);
ELSE IF SALLY
return reblex_display_block(199);
ELSE IF JAMIE
return reblex_display_block(554);
}
add_shortcode('coolshortcodename', 'my_shortcode_function');
2
Answers
basically you have to check the current user id by get_current_user_id()
here is the code that i have modified. I think it will work for you.