blank473
blank473

Reputation: 83

Trying to use a Get_user_meta variable breaks my site

I am having a weird problem. Anytime I try to use a variable I get from the WordPress function get_user_meta, it breaks the site. It is weird because every other variable works just fine and is coded exactly the same. Wether they are empty or not.

        $is_optionalcopd_completed = get_user_meta( $user_id, 'is_optionalcopd_completed' );

        $is_optionalasthma_completed = get_user_meta( $user_id, 'is_optionalasthma_completed' );

the bottom one works just fine, but if i even try to echo out $is_optionalcopd_completed, i just get a white screen

Any ideas what the problem may be?

Upvotes: 0

Views: 284

Answers (2)

Benoti
Benoti

Reputation: 2210

Even if the user meta doesn't exists, it will not returns a blank screen, it returns an empty string.

Does your code use it after you want to echo it ?

I suggest you to verify if there is no typo error in the code.

Do you see this user meta with a var_dump(get_user_meta($user_id)); ?

That's only hints, waiting for more element to help ;-)

Upvotes: 0

Thijs
Thijs

Reputation: 1012

Do you get any php errors (WP_DEBUG enabled)? Try to use var_dump() instead of echo, because get_user_meta() returns default a array.

Like the notes state: make sure the meta value exists https://codex.wordpress.org/Function_Reference/get_user_meta#Notes.

Upvotes: 1

Related Questions