Im trying to make a simple user listing in a dropdown select box using contact form 7 Anyone see what im doing wrong? Just trying to simply obtain all the users and display them in the selection box. But im running into trouble when trying to work this into my contact form 7 plugin.
wpcf7_add_shortcode('postdropdown', 'createbox', true);
function createbox(){
global = $wpdb;
$blogusers = get_users( array( 'fields' => array( 'display_name' ) ) );
$output = "
<select name='cursus' id='cursus' onchange='document.getElementById(\"cursus\").value=this.value;'>
<option></option>";
foreach ( $blogusers as $user );
$output .= "<option value='$user'> $user </option>";
endforeach;
$output .= "</select>";
return $output;
}
Any help would be great! Brook
</div>
To display the name you need to use $user->display_name
as show in WordPress Codex for get_users
Also there is not need for $wpdb
and its not declared correctly. You don't add =
sign, check Variable Scope in PHP