Skip to content

Instantly share code, notes, and snippets.

@iamandrewpeters
Last active October 18, 2018 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamandrewpeters/b4126f78f89de83c729b1d679658bb9b to your computer and use it in GitHub Desktop.
Save iamandrewpeters/b4126f78f89de83c729b1d679658bb9b to your computer and use it in GitHub Desktop.
Create a Welcome Widget in the Dashboard
//Add Welcome Widget
//Register the Widget
function reachco_welcome_metabox() {
// Get the current logged in user.
$current_user = wp_get_current_user();
// Grab the users first name.
$name = $current_user->user_firstname;
// Ad the widget. Note that 'normal' places top left and 'side' places top right
add_meta_box( 'reach_hello_widget', 'Welcome back, ' . $name . '', 'reach_hello_widget_output', 'dashboard', 'normal', 'high' );
}
//Register Widget Output
function reach_hello_widget_output() { ?>
Welcome to your custom site from <a href="https://thereach.company">The Reach Company!</a><br><br>
Here are a few links to help you out. And as always, we are just an <a href="https://thereach.company/support">email away</a>.<br><br>
<ul style="overflow:hidden;margin:0;">
<li style="width:50%;float:left;"><a href="/tutorials">View Your Tutorials</a></li>
<li style="width:50%;float:left;"><a href="https://thereach.company/support">Get Support</a></li>
<li style="width:50%;float:left;"><a href="https://kb.myreach.site">View the Knowledge Base</a></li>
<li style="width:50%;float:left;"><a href="https://unsplash.com">Find New Photos</a></li>
<?php }
add_action( 'wp_dashboard_setup', 'reachco_welcome_metabox' );
/**Add Custom Welcome Widget Simple Setup
*Just had to replace the written content with your own
*This does not position the widget
*/
//Register the Widget
add_action('wp_dashboard_setup', 'reachco_dashboard_widgets');
function reachco_dashboard_widgets() {
global $wp_meta_boxes;
//Adding the output
wp_add_dashboard_widget('custom_help_widget', 'Welcome to your Reach Co site', 'custom_dashboard_help'); //Replace my title with yours
}
function custom_dashboard_help() {
echo 'Welcome to your custom site from <a href="https://thereach.company">The Reach Company!</a><br><br>
Visit your <a href="/tutorials">Tutorials</a> page to access your sites custom tuts.
If you need support you can reach us <a href="https://kb.myreach.site">here</a>. We will be in touch soon after you submit your support request.'; //Replace my content with yours
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment