Hi:
Unfortunately, we don’t have anything built-in that handles custom queries – all we have built-in are the taxonomy drop-downs.
You would have to write all your own php code to handle this. You can use any of the action hooks in themes/submission.php to execute your query and render the drop-down. You have hooks in that file before and after most fields so you can render your customer query drop-down just about anywhere on the form.
I hope this helps.
Hi, thanks for the answer. I tried to use my own code but I have some issues in understanding where to hook it. Since I want to recover the data dynamically from the DB, but that is different to each logged-in user (I need to use wp_get_current_user()), I think hooking to “plugins_loaded” as in your custom fields guide is not the way, as it will not distinguish each user. I tried hooking to “wpas_get_custom_fields” (as in the code below), but though it seems to work better still it does not seem to find “wpas_add_custom_field” (I have an alert sent if the code enters the “If” part and it doesn’t). Any suggestion on the hook and on how to make the code find “wpas_add_custom_field” (even removing the “if” the code does not work, obviously)?
Thanks a lot
Reference code:
add_action( ‘wpas_get_custom_fields‘, ‘wpas_user_custom_fields’ );
function wpas_user_custom_fields() {
if ( function_exists( ‘wpas_add_custom_field’ ) ) {
//My code to get SQL data (which works)
wpas_add_custom_field( ‘myname’, $array_from_SQL);
return;
}
}
}
To add to my comment, I also tried to copy/paste the code on your custom fields article but it does not seem to show any additional custom field in my forms (using the “plugins_loaded” hook)… not sure what I am doing wrong
Hi – can you tell me which custom fields article you copied and pasted from?
Thanks.