Mike Waller
asked on
trying pulling back all users
I'm trying to pull back all users from my db using a php script. What do I need to adjust to make that happen?
<?php
foreach(get_users() as $user)
{
$user = new WP_User($user);
// print_r($user); for a list of properties available for display.
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also, in phpmyadmin, I see listed out in the usermeta table the following on each user:
a:1:{s:15:"s2member_level1 ";s:1:"1"; }
Is that the role that I'm referring to in that query above?
a:1:{s:15:"s2member_level1
Is that the role that I'm referring to in that query above?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The code can go anywhere in your themes template files.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
but I have php execution installed so I should be able to view that inside a page, right?
ASKER
okay, I placed the code above in a separate php page outside of wordpress and nothing gets displayed in the output. Permissions on all directories off of root are at 777 too.
<?php
$wp_user_search = $wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID");
foreach ( $wp_user_search as $userid ) {
$user_id = (int) $userid->ID;
$user_login = stripslashes($userid->user_login);
$display_name = stripslashes($userid->display_name);
$return = '';
$return .= "\t" . '<li>'. $display_name .'</li>' . "\n";
print($return);
}
?>
ASKER
Okay, I placed the code inside my functions.php page and names were displayed so that's good. I realized that it had to fall under wordpress framework. There is no header.php with this theme I'm using.
So if I can get it to pull back data through the functions.php page, then the issue is why can't I have that data display on a page?
So if I can get it to pull back data through the functions.php page, then the issue is why can't I have that data display on a page?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If I the code in above, then view the source code on the page, the source code stops at <div class="entry-content">
What would that indicate?
What would that indicate?
ASKER
Okay, I tried var_dump($wp_user_search); and yes it display the results. Also, I put up a header.php page and can list out the display names just fine. It's just that when I try to add that php code in the html tab on a page, no names appear and in the source code, it stops at this line of code: <div class="entry-content">
ASKER
Okay, I have it pulling back data now on the page using the following:
<?php
foreach (get_users () as $user)
{
$user = new WP_User ($user->ID);
echo get_user_field ("age", $user->ID);
print_r(get_s2member_custo m_fields($ user->ID)) ;
print_r($user);
}
?>
However, it pulls back all the data on the user in an array. How then would I parse out just the display name using the above code?
<?php
foreach (get_users () as $user)
{
$user = new WP_User ($user->ID);
echo get_user_field ("age", $user->ID);
print_r(get_s2member_custo
print_r($user);
}
?>
However, it pulls back all the data on the user in an array. How then would I parse out just the display name using the above code?
ASKER
Thanks!
ASKER
Any idea what I'm missing?
Open in new window