Could be on some compatibility issue.
According to http://codex.wordpress.org/Function_Reference/wp_get_current_user the following fields are returned.
user_login
user_email
user_firstname
user_lastname
display_name
ID
All of which are returned on my ‘English’ version; none of which are returned on my ‘German’ version.
In fact I get 15 more ‘English’ fields than ‘German’ ones.
What I am finding difficult is –
I have the same database and tables,
I have common PHP code,
both instances are running on my localhost
The only difference seems to be the fields returned by
wp_get_current_user() and
get_userdata( $user_id )
Is it possible that the ‘German’ version is really so different from the ‘English’ version.
Would a developer care to comment, please?
The only difference between the two versions should be the language files. Have you asked about this on the German WordPress support forums?
I agree with you, esmi. That is what is so puzzling.
Yes a question has been asked on the German Forum, by a colleague in Germany. Since I do not understand German, I am awaiting an update from him.
I’ll add to this thread when I have more information.
No update on the German Forum.
I have installed PHP Execution Plugin on both the English and German instances.
On both I created a page entitled ‘PHP and inserted the following code
[ Moderator Note: Please post code or markup snippets between backticks or use the code button. Not blockquote or pre. ]
<?php
echo ('this is an echo');
$user_id = 1;
$old_data = wp_get_current_user();
$new_user_data = get_userdata( $user_id );
?>
<?php
print_r ($old_data);
echo ( 'next is the new data ' );
print_r ($new_user_data);
?>
The page shown is different on the two instances.
The English version shows 290 lines
The German version shows 197 lines
The significant difference for me and my German colleague is in the first part, where …
GERMAN =====
WP_User Object
(
[data] => stdClass Object
(
[ID] => 1
[user_login] => admin
[user_pass] => $P$B2DMuyDNV4F/AOSuKUcJdvdj9mPKT70
[user_nicename] => admin
[user_email] => ken@kalsom.co.uk
[user_url] =>
[user_registered] => 2012-10-12 12:33:56
[user_activation_key] =>
[user_status] => 0
[display_name] => admin
)
[ID] => 1
ENGLISH ======
WP_User Object
(
[data] => stdClass Object
(
[ID] => 1
[user_login] => Kharry
[user_pass] => $P$BzMbXQzzX9xE0KRODeYQ1xonBzFxrA1
[user_nicename] => kharry
[user_email] => ken@kalsom.co.uk
[user_url] =>
[user_registered] => 2012-10-11 06:06:33
[user_activation_key] =>
[user_status] => 0
[display_name] => Kharry
[first_name] => Ken
[last_name] => Brewer
[nickname] => Kharry
[description] =>
[rich_editing] => true
[comment_shortcuts] => false
[admin_color] => fresh
[use_ssl] => 0
[show_admin_bar_front] => true
[show_admin_bar_admin] => false
[aim] =>
[yim] =>
[jabber] =>
[wp_capabilities] => Array
(
[administrator] => 1
)
[wp_user_level] => 10
[wp_usersettings] => m7=c&m9=c&m8=c&m6=c&m5=c&m10=c&m11=c&m0=o&m2=c&m4=o&editor=html&m1=c&hidetb=1&align=left
[wp_usersettingstime] => 1351071898
[wp_dashboard_quick_press_last_post_id] => 91
[managenavmenuscolumnshidden] => Array
(
[0] => link-target
[1] => css-classes
[2] => xfn
[3] => description
)
[metaboxhidden_navmenus] => Array
(
[0] => add-post
[1] => add-post_tag
)
[nav_menu_recently_edited] => 3
[closedpostboxes_page] => Array
(
)
[metaboxhidden_page] => Array
(
[0] => postcustom
[1] => slugdiv
[2] => authordiv
[3] => revisionsdiv
)
[user_level] => 10
[user_firstname] => Ken
[user_lastname] => Brewer
[user_description] =>
)
[ID] => 1
The database tables look the same,
My plugin code is common
The two functions should return the same data.
WHY DON’T THEY?
BTW any other German version Users running into problems?
esmi,
A year ago you advised someone to use get_userdata($userid) to obtain first name and last name. This doesn’t seem to work for the German version of 3.4.2
This is a real learning exercise for me. I’ll pass on what I think I’ve learned so far.
- The ‘English’ Version of WordPress is different from the ‘German’ version. I was expecting the only real difference to be in the language, not the code
- pluggable.php is different
- user.php is different
- wp_get_current_user() returns different data. The ‘German’ version returns
WP_User Object
(
[data] => stdClass Object
(
[ID] => 1
=======
[display_name] => John
)
The ‘English’ version returns the same plus
[first_name] => Ken
[last_name] => Brewer
etc.
And the results for get_userdata($userid). The German version returns
WP_User Object
(
[data] => stdClass Object
(
[ID] => 1
=======
[display_name] => admin
)
The ‘English’ version returns the same plus
[first_name] => Ken
[last_name] => Brewer
etc.
So now my questions are?
- Why is the German code so different?
- How do we get the German code to return
- user_firstname
- user_lastname
- nickname
- user_email
- user_url
- user_description
- user_pass?