How can I add an admin panel visible to subscribers only so they can click and go to a special page on the front end?
Right now I have the dashboard hidden for them and just the profile showing. I would like to have this extra panel so they can easily go to a help page.
It doesn't need to be a menu panel though. Any link that I can add to the top of the profile page would also help.
Any help is very much appreciated.
Thanks in advance!
Try it with this in your theme's functions.php for the link on top of the profile page:
global $pagenow;
if(is_admin() && $pagenow == 'profile.php' && current_user_can('subscriber')) {
add_action( 'all_admin_notices', 'my_show_extra_profile_link' );
}
function my_show_extra_profile_link( $user ) {
echo '<a href="mylink here">my link here</a>';
}
For it to show up at the bottom of the profile page use something like this:
if(is_admin() && current_user_can('subscriber')) {
add_action( 'show_user_profile', 'my_show_extra_profile_link' );
}
function my_show_extra_profile_link( $user ) {
echo '<a href="mylink here">my link here</a>';
}
keesiemeijer,
Thank you so much!
It worked like a charm!!!
You're welcome. Glad you got it resolved.
Hope this will make your life easier, enjoy :)
if(is_admin()) {
add_action('admin_menu', 'my_menu');
}
function my_menu() {
add_menu_page('My Page Title', 'My Menu Title', 'subscriber', 'my-page-slug', 'my_function');
}
function my_function() {
echo 'Hello world!';
}