Change WordPress user roles and capabilities Forums Give user access to plugin – how to Need to Provide Access to Newletter plugin please help!

This topic contains 3 replies, has 2 voices, and was last updated by  Vladimir 1 month, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5799

    alijandro
    Participant

    Hey all if you could help me please. I need to give the author role on my site access to the newsletter plugin. Plugin wordpress homepage is:

    Newsletter

    Any guidance help here is most appreciated.

    #5800

    alijandro
    Participant

    These page permissions are missing: resume_plugins / resume_themes

    I have searched the lists for all there worth and cannot find either of these options. The view page permissions states I need these to allow others to view this plugin. Can you help please.

    #5802

    Vladimir
    Keymaster

    resume_plugins and `resume_themes’ capabilities are not created by wordpress as all other WP built-in user capabilities. This capabilities are added by WordPress to the user automatically in case user has correspondent WP default capability:

    
    /**
     * Filters the user capabilities to grant the 'resume_plugins' and 'resume_themes' capabilities as necessary.
     *
     * @since 5.2.0
     *
     * @param bool[] $allcaps An array of all the user's capabilities.
     * @return bool[] Filtered array of the user's capabilities.
     */
    function wp_maybe_grant_resume_extensions_caps( $allcaps ) {
    	// Even in a multisite, regular administrators should be able to resume plugins.
    	if ( ! empty( $allcaps['activate_plugins'] ) ) {
    		$allcaps['resume_plugins'] = true;
    	}
    
    	// Even in a multisite, regular administrators should be able to resume themes.
    	if ( ! empty( $allcaps['switch_themes'] ) ) {
    		$allcaps['resume_themes'] = true;
    	}
    
    	return $allcaps;
    }
    

    As you can see from the code above, user with ‘activate_plugins’ automatically can ‘resume_plugins’ and user with ‘switch_themes’ automatically can ‘resume_themes’.

    #5803

    Vladimir
    Keymaster

    ‘Newsletter’ plugin was written in special way: it defines admin menu items with virtual capability ‘exist’ which available to any user.

    ‘Newsletter’ applies/checks permissions before it defines admin menu items. It’s not friendly to the WordPress user capabilities system. It uses directly WordPress built-in roles: administrator or editor (if it’s allowed at the plugin settings page – “Enable access to blog editors”. Parts of menu is available for the ‘administrator’ role only:

    
    function is_allowed() {
            return current_user_can('administrator') || $this->options['editor'] == 1 && current_user_can('editor');
        }
    
        function admin_menu() {
            if (!$this->is_allowed()) return;
           
            add_menu_page('Newsletter', 'Newsletter', 'exist', 'newsletter_main_index', '', plugins_url('newsletter') . '/images/menu-icon.png', '30.333');
    
            $this->add_menu_page('index', __('Dashboard', 'newsletter'));
            $this->add_admin_page('info', __('Company info', 'newsletter'));
           
            if (current_user_can('administrator')) {
                $this->add_menu_page('welcome', __('Welcome', 'newsletter'));
                $this->add_menu_page('main', __('Settings and More', 'newsletter'));
                $this->add_admin_page('smtp', 'SMTP');
                $this->add_admin_page('status', __('Status', 'newsletter'));
            }
        }
    

    So User Role Editor will not help you with access to this plugin for a custom role. It would be possible only after direct editing of the code above and other.

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

You must be logged in to reply to this topic.