Skip to content

Instantly share code, notes, and snippets.

@gmax21
Last active August 29, 2015 14:07
Show Gist options
  • Save gmax21/74a062bf9cc67a94dec9 to your computer and use it in GitHub Desktop.
Save gmax21/74a062bf9cc67a94dec9 to your computer and use it in GitHub Desktop.
Member wanted code that would add a second button to his BuddyPress install that sends the admins of each site to a frontend page. http://premium.wpmudev.org/forums/topic/button-to-redirect-users-to-the-marketpress-frontend-page-store-admin-page
function bp_get_blogs_visit_store_admin_button( $args = '' ) {
$defaults = array(
'id' => 'store_admin_blog',
'component' => 'blogs',
'must_be_logged_in' => false,
'block_self' => false,
'wrapper_class' => 'store-admin-button visit',
'link_href' => bp_get_blog_permalink() . 'store-admin',
'link_class' => 'store-admin-button visit',
'link_text' => __( 'Store Admin', 'tkb_store_button' ),
'link_title' => __( 'Store Admin', 'tkb_store_button' ),
);
$button = wp_parse_args( $args, $defaults );
// Filter and return the HTML button. This checks if the user has the manage_options capability for the blog by it's ID
$caps = 'manage_options';
if (current_user_can_for_blog(bp_get_blog_id(), $caps)){
echo bp_get_button( apply_filters( 'bp_get_blogs_visit_blog_button', $button ) );
}
}
add_action( 'bp_directory_blogs_actions', 'bp_get_blogs_visit_store_admin_button' );
@gmax21
Copy link
Author

gmax21 commented Oct 13, 2014

This can be added into the theme function.php

Or downloaded as a plugin from the members ticket:

http://premium.wpmudev.org/forums/topic/button-to-redirect-users-to-the-marketpress-frontend-page-store-admin-page

@gmax21
Copy link
Author

gmax21 commented Oct 13, 2014

Some minor CSS to put the buttons on one line with a small gap, tested in Twenty Eleven:

.store-admin-button{float:left;} .blog-button{float:right; margin-left:5px}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment