• Resolved tictok

    (@tictok)


    I’d like to know, on a page, how to generate a list of links to sites a user belongs to in a multisite network?

    Here’s my scenario:

    Currently my clients log into the main ‘master’ site, and a login redirect plugin sends them to their own site which I’m developing for them.

    i.e. Client ‘A’ logs in at the main site and gets re-direted to Client ‘A’ site.
    Client ‘B’ logis in at the main site and gets sent to Client ‘B’ site.

    Currently I do this with 6 or 7 clients and their respective sites. I have to set each client up as a user on the main site as well as on their own site and then use a redirect plugin to automatically send them to their own site after logging in based upon their user name.

    Now I have a client which I am developing 3 themes / sites for. I only want them to need to remember one username and password. What I’d like is once they have logged in at the main site they are taken to a page on the main site (via a redirect plugin to keep them out of the backend) where they are shown a list of links to sites they are a member of (within the multisite network) allowing them to chose which site they visit.

    Is it possible to do this? Is there a plugin? or maybe a snippet of PHP like get_user_sites() or similar?

    Many thanks – really grateful for any help!
    Stef

Viewing 15 replies - 1 through 15 (of 15 total)
  • There is a function like that, but it only lists the sites they are administrator on.

    Also see under Dashboard -> My sites.

    I only want them to need to remember one username and password.

    This is built in. They only *need* one username and password for however many sites they belong to in the entire network.

    Works like wordpress.COM does.

    Similar functionality is built in to BuddyPress; it might be worth a look.

    Users can login at the home blog, or any individual blog, and the BuddyPress Admin Bar, along the top of their screen, offers a drop-down “My Blogs” menu. These are all the blogs for which the user has any role. That offers not just a list of those blogs, but also, for each, menu options for Dashboard, New Post, Manage Posts and Manage Comments.

    It remains in place while they’re working on any blog, so there’s no need to return to the home blog to switch from blog to blog.

    It looks like this: https://screencast.com/t/hCkmbXJ7rf

    Thread Starter tictok

    (@tictok)

    Hi Andrea_r – thanks for your quick reply!

    There is a function like that, but it only lists the sites they are administrator on.

    Also see under Dashboard -> My sites.

    That’s a bit of a problem, anything other than an admin would be fine, but as I’m tidying up and simplifying the backend as much as possible (except for admin = me) I can give them admin privileges.

    Anyway to list on a front end page what sites a user belongs to?

    This is built in. They only *need* one username and password for however many sites they belong to in the entire network.

    Doh! I realised that just after I posted.

    I need to find a way a user can select which site to visit from a dynamically generated list of links (showing only sites they have access to).

    Guessing its a no go? I realise I’m not really using multisite networks for the purpose it was created, but am instead bending it into a kind of development area to show clients sites in progress.

    Thanks
    Stef

    The admin bar is being built in the the next version. it will show – on the front end – a bar with a drop-down of the sites the user belongs to.

    I need to find a way a user can select which site to visit from a dynamically generated list of links (showing only sites they have access to).

    <?php
    if(is_user_logged_in()) {
    global $current_user;
      $blogs = get_blogs_of_user( $current_user->id );
         if($blogs) {
         	 foreach ( $blogs as $blog ) {
             echo '<li><a href="https://' . $blog->domain . $blog->path .'">' .  $blog->blogname . '</a></li>';
    		}
         }
    }
    ?>
    Thread Starter tictok

    (@tictok)

    Thanks guys –

    Andrea_r: Fantastic news! I know its a bad question to ask, a bit like asking how long a piece of string is, but do you have any idea of an ETA?

    David Sader: Haven’t tried it yet, but I’m about to. Looking at the code you’ve posted it looks to be exactly what I was looking for. get_blogs_of_user() appears to be the function I was looking for!

    Thanks again. I’ll let you know how it goes!

    Thread Starter tictok

    (@tictok)

    David, the php snippet you posted works perfectly!
    Many thanks, you’re a star.. problem solved ??

    @tictok end of year I think. It’s in trunk already.

    Thewayx

    (@thewayx)

    Hello: I need the same function but I don’t know what’s the best position to put the David Sader’s snippet.

    Many thanks.

    Wherever you want the list to show.

    Thread Starter tictok

    (@tictok)

    Exactly as Andrea_r says, wherever you want the list to show.

    It depends upon the templates or theme you are using and which page you want the list to appear on. It’ll probably be a little bit different for everyone. It’s really impossible to show you where without see your theme / templates and you deciding where you want the list to be displayed.

    You will need to at least be a little comfortable either editing or creating template files.

    Another, fairly rough possibility would be to use a plugin for a widget that allows PHP to be parsed run within the widget and put the PHP snippet within there. Assuming your theme is setup to use widgets of course!

    Cheers
    tStef

    Thewayx

    (@thewayx)

    Many thanks for your reply.

    I use Atahualpa theme and editing the header, the php snippet works perfectly, but not pretty. I tried to include the code in one widget (calendar, login with ajax, . . .) but I don’t have lucky day. At this time you know I don’t know php.

    I wish the new version coming soon!

    Many thanks again.

    Thread Starter tictok

    (@tictok)

    hey –

    Yep, its not pretty without any styling. You’d have to maybe wrap the php code in a div or some other markup and style the output with CSS.

    As for widgets, try this one;
    https://www.ads-software.com/extend/plugins/wp-php-widget/

    Haven’t tried it myself, so can’t guarantee it’ll work, but it appears to allow you to include PHP code, template tags etc within the widget.

    Good luck!

    Thewayx

    (@thewayx)

    Incredible!!!!!
    Incredible!!!!!
    Incredible!!!!!

    It works perfectly!

    Thank you very very much.

    The code above outputs the lists in li tags, so wrap it in ul tags too. Then style.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘List which sites a multisite user belongs to?’ is closed to new replies.