Home › Forums › General Issues › Set current user as default in relational select field › Reply To: Set current user as default in relational select field
Yeah thanks. I needed to be sure in what way you’re creating the field 🙂
You should be able to set a default value of the current user using this filter:
http://www.advancedcustomfields.com/resources/acfload_field/
This code should work just fine! Be sure to change the field_name to your own. If you want to be safe you can also change it to use the field key instead.
function user_acf_load_field( $field ){
$field['value'] = get_current_user_id();
return $field;
}
// acf/load_field - filter for every field
add_filter('acf/load_field/name=userfield', 'user_acf_load_field');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.