Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am creating a multi-user, multi-product, multi-product-category reservations engine proof of concept. As I need to build it really fast I am using Wordpress's custom post types to manage a lot of the data.

I have reached a cross roads as I have modelled individual reservations as a post type, however, as the ones who will be making said reservations may not be registered and/or will be users with the subscriber role. Is it possible for them to still create a reservations post type?

share|improve this question
    
Sure. I'd say that's readily possible. Are you doing this all custom or are you existing using plugins? (e.g. Gravity Forms has some nice add-ons that sound like they'd do a lot of what you've described). –  Jonathan Wold Feb 7 '13 at 23:48
add comment

2 Answers

Read about roles and capabilities on codex: http://codex.wordpress.org/Roles_and_Capabilities

share|improve this answer
    
While roles and capabilities might be related to a solution, merely pointing to the Codex page for those topics isn't a complete answer. Once you get a little bit of rep you can post this kind of thing as a comment. –  s_ha_dum Feb 8 '13 at 1:28
    
@s_ha_dum I know, I would've written it in a comment, but couldn't do. –  NeS Feb 8 '13 at 1:30
add comment

Assuming you have 'reservations' custom post type:

function my_add_capabilities() {
    $role_obj = get_role('subscriber');
    $role_obj->add_cap('edit_reservations');
    $role_obj->add_cap('publish_reservations');
    $role_obj->add_cap('delete_reservations');
}

As capabilities are stored in database, hook this function to the theme activation hook such as switch_theme to add capabilities only when theme is switched. You'll need to switch the theme to any other and back to yours in admin panel.

add_action('switch_theme', 'my_add_capabilities');

Function Reference/add_cap.

If you want to remove capabilities, use remove_cap function in likely manner. You need to run it once.

function my_remove_capabilities() {
    $role = get_role('subscriber');
    $role_obj->remove_cap('edit_reservations');
    $role_obj->remove_cap('publish_reservations');
    $role_obj->remove_cap('delete_reservations');
}
add_action('admin_init', 'my_remove_capabilities');

Function Reference/remove cap

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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