• Resolved stuureenswatnaarhugo

    (@stuureenswatnaarhugo)


    Hello,

    I would like to generate a list of users who have a URL filled in in their profile. But! I want to exclude those who don’t.
    I already found this:

    <br />
    <?php $blogusers = get_users_of_blog(); //gets registered users<br />
    if ($blogusers) {<br />
    foreach ($blogusers as $bloguser) {<br />
    $user = get_userdata($bloguser->user_id); //gets the actual data about each user<br />
    echo $user->display_name." <a>user_url."\">".$user->user_url."</a><p>".$user->description."</p>";<br />
    if ($user->user_level == 10) {echo "<b>Admin</b>"; }<br />
    }<br />
    }<br />
    else { echo "Bizarrely, your blog appears to have no users. Something weird has happened."; }</p>
    <p>?><br />

    And it’s working, but I don’t know how to exclude members without website, right now it’s displaying all members…

    Thank you very much, you wise people!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Not sure what’s up with all those <br /> tags, but replace that code with this:

    <?php $blogusers = get_users_of_blog(); //gets registered users
    	if ($blogusers) {
    		foreach ($blogusers as $bloguser) {
    			$user = get_userdata($bloguser->user_id); //gets the actual data about each user
    			if ($user->user_url) {
    				echo $user->display_name.' <a href="'.$user->user_url.'">'.$user->user_url.'</a>';
    				echo '<p>'.$user->description.'</p>';
    				if ($user->user_level == 10) {
    					echo '<b>Admin</b>';
    				}
    			}
    		}
    	} else {
    		echo 'Bizarrely, your blog appears to have no users. Something weird has happened.';
    	}
    ?>

    Should work just fine. If not, try changing
    if ($user->user_url) {
    to
    if (!$user->user_url == '') {

    Let me know.

    Thread Starter stuureenswatnaarhugo

    (@stuureenswatnaarhugo)

    Nick,

    That is working brilliantly! Problem resolved…

    Thank you!
    Hugo

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘I want a list of users who have a url (and exclude those who don’t)’ is closed to new replies.