Support

Account

Home Forums Front-end Issues ACF Form – allow logged-out users to create terms in taxonomy Reply To: ACF Form – allow logged-out users to create terms in taxonomy

  • I figured out how to do this but do not recommend it. A better way would be to add an “other” option which reveals a text field and then use the acf/save_post action to add the content of the text field as a new taxonomy term.

    Here is the process to solve the originally asked problem. Start by creating a user named “Website Visitor” or similar with Subscriber-level access. Then integrate the following code.

    // Allow all users, even non-signed in users to manage categories/taxonomies
    add_filter( 'user_has_cap', 'custom_allow_all_edit_tax');
    function custom_allow_all_edit_tax($allcaps){
        $allcaps['manage_categories'] = true;
        return $allcaps;
    }
    
    // Set the user to your manually created "Website Visitor" user with Subscriber-level access
    add_action('after_setup_theme', 'custom_set_user_website_visitor');
    function custom_set_user_website_visitor(){
        // You will want to check if the user is not logged in already before modifying the user here
        wp_set_current_user(#); // Your Website Visitor's user number
    }