I am creating a plugin where I need to select other users except me(current user who is logged in).
$user_id = get_current_user_id();
wp_dropdown_users(array(
'name' => 'user',
'exclude' => '$user_id,1',
'show' => 'user_login'
));
is not providing required result. How to overcome this issue?
Your problem is here:
This will generate the string ‘$user_id,1’, it won’t insert the user ID into your string.
The reason for this is the difference between ‘$hello’ and “$hello” E.g.
So using double rather than single quotes would fix your issue.
An even more reliable way
Use string concatenation to tie them together instead, e.g:
The . operator joins two strings together, e.g.:
A more generic way
Use an array, and use
implode
to generate the stringI recommend you read up on magic quotes in basic PHP and string handling