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:
I get the userdata with these two lines:
$user_data = get_userdata( $user_id );
$user_data->user_email;
which works for all fields – exept those with dashes in them! I have tried this:
$user_data = get_userdata( $user_id );
$user_data->date-of-birth;
which just returns 0
. And this:
$user_data = get_userdata( $user_id );
$user_data->date_of_birth;
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.
Try this:
It’s weird looking but should work. 🙂