submit for review

When members try to post a classified ad it only has a "submit for review" button but no "publish" button. I am using a custom role defined like so:

function add_roles_on_plugin_activation() {
add_role( 'custom_role', 'Member', array(
'read' => true,
'edit_posts' => true,
'delete_posts' => true,
'publish_posts' => true,
'upload_files' => true,
) );
}
register_activation_hook( __FILE__, 'add_roles_on_plugin_activation' );

  • Adam Czajczyk

    Hello Stephen,

    I hope you're well today and thank you for your question!

    Classified ads are posts of custom type but there's additional capabilities control built-in. You may grant/withdraw detailed capabilities to selected user roles directly on plugin's settings pages. To do this please to to the "Classifieds -> Settings -> Capabilities" page, then select your custom user role from the drop-down list and tick checkboxes for selected capabilities.

    I hope that helps!
    Best regards,
    Adam

  • Predrag Dubajic

    Hi Stephen,

    I did some further tests on this and looks like classifieds can't be published from back end directly without setting manage_options as true.

    So changing your function to this did the trick for me:

    function add_roles_on_plugin_activation() {
    	add_role( 'custom_role', 'Member', array(
    		'read' => true,
    		'edit_posts' => true,
    		'delete_posts' => true,
    		'publish_posts' => true,
    		'upload_files' => true,
    		'manage_options' => true,
    
    		) );
    	}
    register_activation_hook( __FILE__, 'add_roles_on_plugin_activation' );

    Best regards,
    Predrag

  • Adam Czajczyk

    Hello stephen!

    I reviewed the plugin's code and I believe that there's been a code added with one of the updates that specifically prevents users from publishing ads from backend. It's been added there on purpose upon community requests.

    I think I found a workaround/solution though that will allow to publish ads to all user roles that are granted "publish_classifieds" capability. Here's the solution:

    <?php
    function allow_publish_backend_cap($data, $cap, $args)
        {
              if (!is_admin()) {
                return $data;
            }
            if (!in_array('publish_classifieds', $cap)) {
                return $data;
            }
            global $current_user;
            if (!isset($current_user->allcaps['manage_options'])) {
                $data['publish_classifieds']=true;
            }
        return $data;
        }
    
    add_action('user_has_cap', 'allow_publish_backend_cap', 11, 3);

    To apply it to your site please create an empty file with a .php extension, paste the code inside and upload the file to the "/wp-content/mu-plugins" folder.

    In case it didn't help or instead it gave "publish" option to other roles (that shouldn't be able to publish) too, simply make sure that "publish_classifieds" capability is granted accordingly to those roles only that should be able to publish ads.

    I hope that helps!
    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.