User role plugin

This topic contains 15 replies, has 2 voices, and was last updated by  CTHthemes 1 year, 5 months ago.

Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #14665

    kclaes
    Participant

    Support Expired

    Hello,
    Thank you for your wonderfull template!
    I am looking for a plugin to create a user role that can only access and change the lambert gallery. Any advice is welcome!
    Thank you
    Katja

    #14674

    CTHthemes
    Keymaster

    You can find more details here: https://wpdean.com/wordpress-plugins-to-extend-user-roles-capabilities/
    Or do google search

    #14690

    kclaes
    Participant

    Support Expired

    Thanks, I was looking in to user role editor but the custom post types such as the gallery don’t have any roles to grant?

    Attachments:
    You must be logged in to view attached files.
    #14698

    CTHthemes
    Keymaster

    What’s the plugin? and I need wp-admin account to check.

    #14706

    kclaes
    Participant

    Support Expired
    This reply has been marked as private.
    #14716

    CTHthemes
    Keymaster

    The gallery post type have no custom capabilities, so you can edit lambert_add_ons plugin to enable it: http://prntscr.com/ftt1hq

    
    //'capability_type' => 'post'
    'capabilities' => array(
        'edit_post' => 'edit_cthgallery',
        'edit_posts' => 'edit_cthgalleries',
        'edit_others_posts' => 'edit_other_cthgalleries',
        'publish_posts' => 'publish_cthgalleries',
        'read_post' => 'read_cthgallery',
        'read_private_posts' => 'read_private_cthgalleries',
        'delete_post' => 'delete_cthgallery'
    ),
    // as pointed out by iEmanuele, adding map_meta_cap will map the meta correctly 
    'map_meta_cap' => true
    

    Also set public option to false to hide galleries from public.

    #14718

    kclaes
    Participant

    Support Expired

    Thank you! By adding that code, the capabilities are now visible.
    What do you mean by: Also set public option to false to hide galleries from public? Visitors need to see the gallery on the website or does this mean something else?

    #14719

    kclaes
    Participant

    Support Expired

    By appending the capabilities for the gallery to a new user, when logging in with that user, I can see everything from Lambert (that has post capabilities) but not the Lambert gallery. Any suggestions?

    #14720

    kclaes
    Participant

    Support Expired

    Forget about my last remark. I forgot to set the correct role to the new user. Now I see the lambert gallery but I cannot edit it.

    • This reply was modified 1 year, 5 months ago by  kclaes.
    #14722

    CTHthemes
    Keymaster

    You can also set edit gallery capability to the user.

    #14727

    kclaes
    Participant

    Support Expired

    In the photo “code” you can see the code I added. Edit gallery is set this way, no?
    The user roles I can see with this code are in “user role capabilities”. What I find strange is that the delete option is not available.
    Logged in I can view the gallery, I can add a new one, but I can not edit an existing gallery nor a newly added one.

    Attachments:
    You must be logged in to view attached files.
    #14733

    kclaes
    Participant

    Support Expired

    I changed the code to this:
    `’capabilities’ => array(
    ‘edit_post’ => ‘edit_cthgallery’,
    ‘edit_posts’ => ‘edit_cthgalleries’,
    ‘edit_others_posts’ => ‘edit_others_cthgalleries’,
    ‘edit_private_posts’ => ‘edit_private_cthgalleries’,
    ‘edit_published_posts’ => ‘edit_published_cthgalleries’,
    ‘publish_posts’ => ‘publish_cthgalleries’,
    ‘read_post’ => ‘read_cthgallery’,
    ‘read_private_posts’ => ‘read_private_cthgalleries’,
    ‘delete_post’ => ‘delete_cthgallery’,
    ‘delete_posts’ => ‘delete_cthgalleries’,
    ‘delete_others_posts’ => ‘delete_others_cthgalleries’,
    ‘delete_private_posts’ => ‘delete_private_cthgalleries’,
    ‘delete_published_posts’ => ‘delete_published_cthgalleries’

    Now I can edit and delete any gallery.

    The only thing I can not change is the category, even not when I give the capability “manage categories”. Do I need to add something to the code?

    Thank you
    Katja

    #14734

    kclaes
    Participant

    Support Expired

    Hello,
    I’ve managed to make the categories editable by adding this function to the them’s function.php:
    function assign_cthgallery_terms(){
    global $wp_taxonomies;

    $wp_taxonomies[‘cthgallery_cat’]->cap->assign_terms = ‘edit_cthgallery’;
    }
    add_action(‘init’, ‘assign_cthgallery_terms’);

    Is it possible to incorporate this into a child theme?

    #14735

    CTHthemes
    Keymaster

    Yes, you can add it to child theme’s functions.php file.
    Or add capabilities definition in cthgallery_cat taxonomy registration code. Read more at: https://wordpress.stackexchange.com/questions/155629/custom-taxonomies-capabilities

    #14766

    kclaes
    Participant

    Support Expired

    I changed the code in cthgallery.php as shown in the picture. Is that correct?

    Attachments:
    You must be logged in to view attached files.
    #14782

    CTHthemes
    Keymaster

    Yes, but you miss a comma character ( , ) after capabilities statement.

Viewing 16 posts - 1 through 16 (of 16 total)

You must be logged in to reply to this topic.

Hello! CityBook version 1.2.7 was released. Bulk Import Add-On, OpenStreetMapView Details
+