Which goes first custom roles or custom capabilities?
-
Everywhere on the net i was searching, no one is mentioning which one goes first and is it possible to use one hook theme activation for both roles and capabilities. They both are saved in database and as i see although they are linked with each other, they are not linked in database as foreign keys, they are even in same option saved.
So my question is as both codex guides references that roles and capabilities should be added or removed on theme/plugin activation, they use different approach.
In add capabilities codex page suggest to run on theme page and check if it’s activated, otherwise remove capability.
add_action( 'load-themes.php', 'add_theme_caps' );
And in roles codex page they suggest register activation hook, which is basically used for plugin activations
register_activation_hook( __FILE__, 'add_roles_on_plugin_activation' );
So which one would be correct? can i use one hook on theme activation to add both new roles and new capabilities. My point is that i want to add a few roles
Confirmed poster Unconfirmed poster Blocked poster
And a few capabilities hooked to those roles like
create_new_listing edit_own_listing delete_own_listing send_private_message edit_own_profile
On top of that “listings” are custom post type so should i also add capabilities to that custom post type too?
register_post_type( 'listings', array( 'public' => true, 'capability_type' => 'listings', 'capabilities' => array( 'publish_posts' => 'create_new_listing', 'edit_posts' => 'edit_own_listings', 'edit_others_posts' => 'edit_others_listing', 'read_private_posts' => 'read_private_listing', 'edit_post' => 'edit_listing', 'delete_post' => 'delete_listing', 'read_post' => 'read_listing', ), ) );
So which order goes on activation and adding custom roles and capabilities?
- The topic ‘Which goes first custom roles or custom capabilities?’ is closed to new replies.