• Resolved kokoruz

    (@kokoruz)


    I have created a custom post type and allowed a custom defined role to be able to post there.

    What I have discovered is as the admin I can post there and an email notification is sent out when I publish the post.

    But

    When one of my Users who have been enabled to Publish a Post in this Post Type the Better Notifications does not send out an email.

    In short, Email sent when Admin Published, Email NOT sent when custom Role Publishes.

    • This topic was modified 4 years ago by kokoruz.
    • This topic was modified 4 years ago by kokoruz.
    • This topic was modified 4 years ago by kokoruz.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author bnfw

    (@voltronik)

    Hi @kokoruz,
    Thanks for your message.

    I haven’t had any issues with this particular scenario myself but can you tell me a bit more about how you’re creating the custom post type and custom user role? How are you limiting posting to the CPT from the user role? My initial thoughts are that it’s some kind of capability issue but i’d like to try and re-create what you’ve done and test it myself too.

    Thread Starter kokoruz

    (@kokoruz)

    I too was thinking this must be a role/capability issue.

    The CPT is all scripted. Not created by a plugin. The role was created through a plugin.

    Under the CPT is have ‘capability_type’ => array(‘team-post’,’team-posts’)

    And under the role I have given access to edit_team-posts, delete_team-posts, publish_team-posts, delete_published_team-posts, edit_published_team-posts.

    As I dig through this plugin I have located a tab called Notifications. It includes bnfw(your plugin) the capability for this custom role is not ticked. I suspect this is my issue. I will tick and confirm but if you have any additional feedback please let me know.

    Thread Starter kokoruz

    (@kokoruz)

    FYI – I have reviewed the default roles and notification from BNFW are not ticked for Author, Contributor, or Editor.

    Based on Roles it would seem Editor and Author this might need to be turned on by default as they both have publishing capabilities by default.

    Thread Starter kokoruz

    (@kokoruz)

    I have just completed my testing. In the custom role, now with the notifications box checked to grant access to your plugin, using the User Switching plugin I have changed to a User in that custom role. I published a post and NO email notification was sent. I switched back to my admin user role, published a new post and YES, a email notification was sent.

    I was really hoping that the issue was just setting the capability for that role to allow for notifications but after testing it seams the issue may be greater.

    I look forward to your response and feedback.

    Thank You.

    Plugin Author bnfw

    (@voltronik)

    Hi @kokoruz,
    That BNFW capability is really only to show the Notifications menu to users that may need to see if but don’t have a higher user role.

    I suspect that it still has something to do with the capabilities. I’m not saying it’s not an issue with BNFW but are you able to test with standard capabilities as well? I suspect that the notifications aren’t triggering as they’re looking at a standard publishing capability and having a custom ones are preventing the correct hooks from firing.

    Thread Starter kokoruz

    (@kokoruz)

    I just published a test post in my CPT as an Author/Role and I did not get a notification using that role.

    Plugin Author bnfw

    (@voltronik)

    Hi @kokoruz,
    In that case, I would suspect it has something to do with your custom post type. Is it set to public?

    I’ve been testing add-ons most of last week with custom post types and haven’t had any issues so I suspect it has something to do with either your CPT or user roles (if you’ve changed the default roles).

    Thread Starter kokoruz

    (@kokoruz)

    Yes, it is set to public and I will research further into Custom Roles and post what I discover. Please do the same.

    function cpt_team_posts() {
    
    $labels = array(
    'name'                  => _x( 'Team Posts', 'Post Type General Name', 'site_intranet' ),
    'singular_name'         => _x( 'Team Post', 'Post Type Singular Name', 'site_intranet' ),
    'menu_name'             => __( 'Team Posts', 'site_intranet' ),
    'name_admin_bar'        => __( 'Team Post', 'site_intranet' ),
    'archives'              => __( 'Item Archives', 'site_intranet' ),
    'attributes'            => __( 'Item Attributes', 'site_intranet' ),
    'parent_item_colon'     => __( 'Parent Team Post:', 'site_intranet' ),
    'all_items'             => __( 'All Team Posts', 'site_intranet' ),
    'add_new_item'          => __( 'Add New Team Post', 'site_intranet' ),
    'add_new'               => __( 'Add New', 'site_intranet' ),
    'new_item'              => __( 'New Team Post', 'site_intranet' ),
    'edit_item'             => __( 'Edit Team Post', 'site_intranet' ),
    'update_item'           => __( 'Update Team Post', 'site_intranet' ),
    'view_item'             => __( 'View Team Post', 'site_intranet' ),
    'view_items'            => __( 'View Team Posts', 'site_intranet' ),
    'search_items'          => __( 'Search Team Post', 'site_intranet' ),
    'not_found'             => __( 'Not found', 'site_intranet' ),
    'not_found_in_trash'    => __( 'Not found in Trash', 'site_intranet' ),
    'featured_image'        => __( 'Featured Image', 'site_intranet' ),
    'set_featured_image'    => __( 'Set featured image', 'site_intranet' ),
    'remove_featured_image' => __( 'Remove featured image', 'site_intranet' ),
    'use_featured_image'    => __( 'Use as featured image', 'site_intranet' ),
    'insert_into_item'      => __( 'Insert into team post', 'site_intranet' ),
    'uploaded_to_this_item' => __( 'Uploaded to this team post', 'site_intranet' ),
    'items_list'            => __( 'Team post list', 'site_intranet' ),
    'items_list_navigation' => __( 'Team post list navigation', 'site_intranet' ),
    'filter_items_list'     => __( 'Filter Team posts list', 'site_intranet' ),
    );
    $args = array(
    'label'                 => __( 'Team Post', 'site_intranet' ),
    'description'           => __( 'Intranet Team Posts', 'site_intranet' ),
    'labels'                => $labels,
    'show_in_rest'          => true,
    'supports'              => array( 'title', 'editor', 'comments'),
    'taxonomies'            => array( 'team-post-sections' ),
    'hierarchical'          => false,
    'public'                => true,
    'show_ui'               => true,
    'query_var'             => true,
    'show_in_menu'          => true,
    'menu_position'         => 5,
    'show_in_admin_bar'     => true,
    'show_in_nav_menus'     => true,
    'can_export'            => true,
    'has_archive'           => true,
    'rewrite'               => array (
    'with_front'            => false,
    'slug'                  => 'team-posts'
    ),
    'exclude_from_search'   => false,
    'publicly_queryable'    => true,
    'capability_type'       => array('team-post','team-posts'),
    'map_meta_cap'          => true,
    );
    register_post_type( 'team-posts', $args );
    
    }
    Thread Starter kokoruz

    (@kokoruz)

    As I did change one of the roles to Author and still had an issue could you please review my CPT and flag anything you see as an issue. Thank You.

    Plugin Author bnfw

    (@voltronik)

    Hi @kokoruz,
    Thanks.

    I’ve been looking into this and I think the issue is something to do with your ‘capability_type’ and ‘capabilities’ for your custom post type. Caps aren’t automatically mapped when they’re created so you’ll need to do this manually, if you haven’t already.

    I found this post, and whilst a little old, does provide a lot of good and useful information that might help: http://justintadlock.com/archives/2010/07/10/meta-capabilities-for-custom-post-types

    Can you work your way through this and let me know if it helps? If not, can you link me to a pastebin/gist of your entire code where you register the post type, map the caps, and assign them to the user role?

    Thread Starter kokoruz

    (@kokoruz)

    I’ll work through this today and post my results

    Plugin Author bnfw

    (@voltronik)

    Closing due to inactivity. If you need further help with this, please feel free to re-open this thread.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Email Post Notification Not Being Sent Out When Custom Role Publishes Post’ is closed to new replies.