Support

Account

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');