How do I reach a specific userdata in the database, when that field has a dash (hyphen) - in the slug?

I use the plugin WP-Members.

I have created a new userdata field with the plugin with the name date-of-birth - by mistake I used these dashes - instead of underscores _. In the database (the usermeta table) it now looks like:

Database screenshot

I get the userdata with these two lines:

$user_data = get_userdata( $user_id );

which works for all fields - exept those with dashes in them! I have tried this:

$user_data = get_userdata( $user_id );

which just returns 0. And this:

$user_data = get_userdata( $user_id );

which of course doesn't work (it gives null), since that is not the correct name.

Is there a method to reach this field with dashes in the slug?

Note I can't change the slug. That is not allowed by this plugin after the field is created.

closed as off-topic by Rarst Sep 22 '13 at 21:48

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions should be specific to WordPress within defined scope (merely happening in its context, such as generic PHP/JS/HTML/CSS, is insufficient). Might be better asked at Stack Overflow or other appropriate site of Stack Exchange network." – Rarst
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Pure PHP magic (or madness) as per answer, not in scope. :) – Rarst Sep 22 '13 at 21:48

Try this:

$user_data = get_userdata( $user_id );

It's weird looking but should work. :-)

  • 1
    Perfect. This works. – Steeven Sep 23 '13 at 7:03
  • Happy to help...! – Eric Sep 23 '13 at 15:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.