Support » Plugins and Hacks » Hacks » Use custom functions code

Use custom functions code

  • Hello,

    I found a code in this forum a while back courtesty of Jim de Groot:

    $roles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
    /* Loop through users to search for the admin and editor users. */
    foreach( $roles as $role )
      	// all users with admin or editor role
    	if($role == 'administrator' || $role == 'editor')
    	  	$this_role = "'[[:<:]]".$role."[[:>:]]'";
    	  	$query = "SELECT * FROM $wpdb->users WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_capabilities' AND meta_value RLIKE $this_role) ORDER BY user_nicename ASC LIMIT 10000";
    	  	$users_of_this_role = $wpdb->get_results($query);
    	  	if ($users_of_this_role)
    	    	foreach($users_of_this_role as $user)
    		    	$curuser = get_userdata($user->ID);
    		      	$author_post_url=get_author_posts_url($curuser->ID, $curuser->nicename);
    				echo "<div class='post'>";
    					echo "<a href='.$user_link.' title='.$curuser->display_name.'>";
    						echo "<h2>$curuser->display_name</h2>";
    					echo '</a>';
    					echo "<a href='.$user_link.' title='.$curuser->display_name'>";
    						echo get_avatar($curuser->user_email, '80', $avatar);
    					echo '</a>';
    					echo '<p>'.$curuser->description.'</p>';
    				echo '</div>';

    What I need to find out is how I can call this as a function? I’m sure this is really simple – but I have tried adding `function test() { …code… } around it with no results. If anyone could point out what i’m doing wrong I would be really grateful.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Use custom functions code’ is closed to new replies.
Skip to toolbar