Support » Plugin: SEO Facebook Comment » [Plugin: SEO Facebook Comments] Dashboard box irrelevant for editors

  • Hi,

    I like your plugin and don’t mind the fact that you force a Plulz News box on the Dashboard homepage. However, this box really should only show up if the user is an administrator. It has zero relevance for editors and authors on my website.

    In the function hookDashboard(), you should add a condition if ( current_user_can(‘manage_options’) ):

    public function hookDashboard()
            {
                // Hook latest news only if its allowed and if user is admin
                if ( current_user_can('manage_options') ) {
                    wp_add_dashboard_widget('PlulzDashNews', 'Plulz Latest News', array( &$this, 'dashboardNews'));
                }
    
                // Lets try to make our widget goes to the top
                global $wp_meta_boxes;
    
                // Get the regular dashboard widgets array
                // (which has our new widget already but at the end)
                $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
    
                // Backup and delete our new dashbaord widget from the end of the array
                $example_widget_backup = array('PlulzDashNews' => $normal_dashboard['PlulzDashNews']);
                unset($normal_dashboard['PlulzDashNews']);
    
                // Merge the two arrays together so our widget is at the beginning
                $sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
    
                // Save the sorted array back into the original metaboxes
                $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
            }

    Alternatively, you could add this condition to the public function __construct():

    public function __construct()
            {
                if ( is_admin() )
                {
                    add_action( 'init', array( &$this, 'adminReceiver' ) );
    
                    add_action( 'admin_init', array( &$this, 'register' ) );
    
                    add_action( 'admin_notices', array( &$this, 'welcomeMessage' ) );
    
                    if ( current_user_can('manage_options') )
                        add_action( 'wp_dashboard_setup', array( &$this, 'hookDashboard' ) );
    
                    if ( !empty($this->menuPage) )
                        add_action( 'admin_menu', array( &$this, 'page' ));
                }
    
                $this->_init();
            }

    Thanks,

    Biranit

    http://wordpress.org/extend/plugins/seo-facebook-comments/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author bemcapaz

    (@bemcapaz)

    Hi Biranit,

    I add the News Box but it can be easily removed in the options, in the header of the main page, by just unchecking the news box checkbox, it can be done to any box in the Dashboard of wordpress 😉

    THIS method is GREAT especially when I want our new users to see a CLEAR dashboard.

    HOWEVER it will have an error LINE appear if I use the facebook button of “SOCIAL LOGIN” Plugin to Login …

    Just a warning error message on the top of “dashboard” though, and everything function very well … I hope somebody could solve this minir “problem”

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: SEO Facebook Comments] Dashboard box irrelevant for editors’ is closed to new replies.