0

I would like to know how can I modify the following code to check if the current user has a site/blog already set up on my wordpress network??

<?php 
global $wp_roles;
foreach ( $wp_roles->role_names as $role => $name ) :
    if ( current_user_can( $role ) && $role == 'administrator') { 
        if ( class_exists( 'MarketpressFadminWidget' ) ) { 
            $mp_frontend_settings = get_option( 'mp_frontend_settings' );
            $mp_frontend_settings = unserialize($mp_frontend_settings);
            $adminpage = $mp_frontend_settings['page_id'];
            $permalink = get_permalink($adminpage);
            ?>
            // My Links / Html Content
            <?php 
        } 
Sam
  • 7,252
  • 16
  • 46
  • 65
730wavy
  • 944
  • 1
  • 19
  • 57
  • Do yourself a favor and stop opening/closing each line with ``, you can write it non-stop and just close/open when printing Html. – brasofilo Nov 28 '12 at 12:36

1 Answers1

1

Use the function get_blogs_of_user.

Description

Returns an array of objects containing the details of each blog the specified user has access to.

Community
  • 1
  • 1
loQ
  • 2,147
  • 18
  • 21
  • Hi, Thanks for your response. However I do not know how to apply this to my code/situation? I have to use the above code. The most important part of the code is ` if ( class_exists( 'MarketpressFadminWidget' ) ) { $mp_frontend_settings = get_option( 'mp_frontend_settings' ); $mp_frontend_settings = unserialize($mp_frontend_settings); $adminpage = $mp_frontend_settings['page_id']; $permalink = get_permalink($adminpage); ?>` Because it is to be used to work the marketpress plugin Im using – 730wavy Nov 29 '12 at 01:31