0

I want to, in a sense use a CPT without registering it. The CPT is used for internal settings by a custom plugin.

For example: I writing a custom form plugin where the website administrator can create separate registration forms for content specific roles (not WordPress roles, a custom system where user's can have multiple roles and content is only visible by roles) and then the form will be saved into the database.

However, instead of having an form "option" using "get_option()" containing all forms created, I would like to use a CPT and save each form individually.

The forms are parsed via custom function and do not need to be searchable, queryable, or accessed by anyone other than the plugin.

So, is it safe to use...

$args = [
    'post_title'=>'Form Title',
    'post_content'=>'Form configuration settings',
    'post_type'=>'custom-form-cpt',
    'post_name'=>'form-name'

];
wp_insert_post( $args );

without actually registering the custom post type? And, then to retrieve the form(s) I will just use "get_post()" or "get_posts()" within the plugin to either show all forms created and/or render the form to screen.

1 Answer 1

0

You need to register a post type to use it with the API. What you're describing is similar to how the revision and nav menu post types behave. Set the public argument to false and the post type will have no administration UI, will be excluded from search, and not publicly queryable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.