2

I am working on a multisite setup and Im trying to display some meta from the site owner's profile. I tried the following code but it is echoing the super admin's meta instead of the current site admin --

 <?php $user_id_from_email = get_user_id_from_string( get_blog_option(get_current_blog_id(), 'admin_email'));

$current_site_admin = get_userdata($user_id_from_email);

$twitt = (get_user_meta($current_site_admin, 'twitter', true)); ?>
<?php echo $twitt; ?>

Since there will be a lot of sites on the network and only one admin, im trying to retrieve this information dynamically. Any ideas on how to fix this?

Thanks

1 Answer 1

2

Ok I figured a way to do it. If anyone else is interested, here's the code. It first gets the user id of the admin of the blog, and then it uses the id to pull the meta from the profile fields.

For one field --

<?php
$thisblog = $current_blog->blog_id;

$user_id_from_email = get_user_id_from_string( get_blog_option($thisblog, 'admin_email'));

$twitt = (get_user_meta($user_id_from_email, 'twitter', true)); ?>
<?php echo $twitt; ?>

And to display multiple fields --

<?php

    $thisblog = $current_blog->blog_id;

    $user_id_from_email = get_user_id_from_string( get_blog_option($thisblog, 'admin_email'));

    $twitt = (get_user_meta($user_id_from_email, 'twitter', true));
    $fb = (get_user_meta($user_id_from_email, 'facebook', true)); ?>
    <?php echo $fb; ?>
    <?php echo $twitt; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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