Forums

[resolved] I want a list of users who have a url (and exclude those who don't) (3 posts)

  1. stuureenswatnaarhugo
    Member
    Posted 2 years ago #

    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!

  2. thenameisnick
    Member
    Posted 2 years ago #

    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.

  3. stuureenswatnaarhugo
    Member
    Posted 2 years ago #

    Nick,

    That is working brilliantly! Problem resolved...

    Thank you!
    Hugo

Topic Closed

This topic has been closed to new replies.

About this Topic