4

I am using WordPress with MU activated. I found a function here that supposed to return an object with the current side ID. But it's returning 1 for all websites.

<?php get_current_site(); ?>
  • The doc block for that function is misleading/wrong. – fuxia Oct 2 '14 at 22:06
4

You're right, get_current_site()->blog_id will return 1, as it refers to the network.

To get the current site (blog) ID you can go like this:

<?php echo get_current_blog_id(); ?>

Moreover you can get the current site (blog) details like this:

<?php var_dump(get_blog_details()->blog_id); ?>
  • 1
    Thank you! Is there a place with documentation for all wpmu functions? Do the old functions (before MU became part of wordpress) still apply? – gdaniel Oct 4 '14 at 1:15
  • @gdaniel Yes, there is a page in the Codex about WPMU functions; as far as I know most of them do still apply :) – Sven Oct 4 '14 at 1:29
0

First of all check whether user belong from current site by using

 <?php is_user_member_of_blog( $user_id, $blog_id ); ?>

After you get id of user create user role

$user = new WP_User( $user_id );
if ( $user ) {
$roles = $user->roles; 

and in last create posts for every user by adding role in args. not tested but i'll do trick for you.

<?php
$args1 = array(
    'role' => 'subscriber',
    'orderby' => 'user_nicename',
    'order' => 'ASC'
);
$subscribers = get_users($args1);
echo '<ul>';
foreach ($subscribers as $user) {
    echo '<li>' . $user->display_name.'['.$user->user_email . ']</li>';
}
echo '</ul>';

?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.