The fields are stored as post/page meta so you can set the meta fields automatically when you create a post/page ex:
add_action('publish_page', 'add_custom_field_automatically');
add_action('publish_post'. 'add_custom_field_automatically');
function add_custom_field_automatically($post_ID) {
global $wpdb;
if(!wp_is_post_revision($post_ID)) {
add_post_meta($post_ID, 'U_S_C_roles', array('Administrator'), true);
}
}
I’m not satisfied with this answer.
Allmost all posts on my site should be private by default except for a few that should be public.
This piece of code would make all posts the same, even after the editor changed the U_S_C settings.
Isn’t it possible to set defaults for the metaboxes on ‘new posts/pages’ so they can be overwritten by editors?
I’m sorry to hear your “not satisfied with this answer”
but I coded this plugin they way i needed it and shared it with the WordPress community the way I like.
Also your use case is not everyone’s use case and not everyone use this plugin the way you do on your site.
I posted a solution to help overcome this “issue” as an example you can use it or not.
You can suggest and request features but not dictate what or how the plugin should work just because you need it that way.
maybe when I’ll find the time or sponsor I’ll add an option to define your defaults.
I didn’t try to dictate you, my apologies if it looked like that.
Consider this my feature request.
To me it seemed helpful for the community to be able to set defaults.
Two solutions are: custom hooks in your plugin or a settingspage for your plugin.
For others looking for a solution, here is mine:
add the following code to your theme’s functions.php
add_action('admin_enqueue_scripts', array($this, 'private_usc_script') );
function private_usc_script($hook) {
if( 'post-new.php' != $hook ){
return;
}
wp_enqueue_script( 'privatecontent', get_template_directory_uri() . '/js/privatecontent.js' );
}
create a new file in your theme’s js folder called ‘privatecontent.js’
jQuery(document).ready(function($){
$('#User_specific_content input[name*=logged]:first').prop('checked',true);
});