Thanks for your answer. At the moment I do not need to add users to a level because I synchronize them with a role.
What I do not understand is the conditions. I see in the database in the table “posts” the record that corresponds to the post type “condition_group”. I see that it is associated with the post id of the level that corresponds to it, but can’t see how the conditions are saved.
In the “postmeta” table I see records like the meta_key _edit_lock are created and as meta_value a numbering of style 1539690142: 1 and other records like _ca_duration, _vc_post_settings etc.
I understand that first I have to add the condition group record like this:
$post_id = wp_insert_post(array (
‘post_type’ => ‘condition_group’,
‘post_title’ => $your_title,
‘post_content’ => $your_content,
‘post_status’ => ‘publish’,
‘post_parent’ => $id_post,
‘comment_status’ => ‘closed’, // if you prefer
‘ping_status’ => ‘closed’, // if you prefer
));
add_post_meta( $post_id, ‘???????????’, ??????????);
And second, I have to add the conditions with this function:
<?php wp_set_object_terms( $object_id, $terms, $taxonomy, $append ); ?>
If you have some time, could you clarify it or give me an example to restrict the post to a category?
Thank you.