Forums

[resolved] How do I display a Dashboard metabox to specific role types? (3 posts)

  1. s3w47m88
    Member
    Posted 1 year ago #

    I am using the following code to display a metabox on the Dashboard, and I want it to only appear for users with a specific role (let's say "Editor" for our purposes). Can anyone refer me to documentation or an example? Thank you!

    /* PROJECT SUMMARY */
    function dashboard_introduction_metabox() {
    	function dashboard_introduction_content() {
    		echo "
    			<p>Sample message.</p>
    		";
    	}
    	wp_add_dashboard_widget( 'dashboard_introduction_content', __( 'An Introduction' ), 'dashboard_introduction_content' );
    }
    add_action('wp_dashboard_setup', 'dashboard_introduction_metabox');
  2. vjpo
    Member
    Posted 1 year ago #

  3. s3w47m88
    Member
    Posted 1 year ago #

    Exactly what I needed, thank you. Here's how I ended up incorporating it:

    [Code moderated as per the Forum Rules. Please use the pastebin]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.