woocommerce_wp_select options for user list

Here is my code for users select option in woocommerce backend. I can not reach dynamic user list in option array.

function woo_add_custom_general_fields() {

echo ‘<div class=”options_group”>’;

$users = get_users( array( ‘fields’ => array( ‘ID’ ) ) );
foreach($users as $key => $term){
$options[$term] = $term;
}

woocommerce_wp_select( array(
‘id’ => ‘_select’,
‘label’ => __( ‘Custom Select Field’, ‘boipoka’ ),
‘options’ => $options
)
);
echo ‘</div>’;
}
add_action( ‘woocommerce_product_options_general_product_data’,’woo_add_custom_general_fields’ );

This code is not correct for dynamic users value and options. It show blank option list now

Read more here:: woocommerce_wp_select options for user list

Leave a Reply

Your email address will not be published. Required fields are marked *