0

i got a php function in Wordpress that get serialized user meta : like this

    function get_allowwed_tournees_ids(){
    $tournees = get_user_meta($this->ID, 'tournees',true);
    $tournees = unserialize($tournees);

    $tournees_ids = array();

    foreach ($tournees as $key => $value) {
        array_push($tournees_ids, $key);
    }

    var_dump($tournees_ids);
    return $tournee_ids;
}

get_allowwed_tournees_ids() is in a class that extends WP_User and when i want to call it :

$id_tournees = $current_user->get_allowwed_tournees_ids();
var_dump($id_tournees);

the var_dump inside the function returns me the unserialised array, and the second var_dump outside the function returns null.

Any idea ?? Thanks !

1
  • You need not use unserialize i guess coz get_usermeta function returns you array or multi dimension array. Commented Mar 7, 2014 at 10:32

1 Answer 1

1

Because you are returning $tournee_ids which is never defined. I think you should

return $tournees_ids;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.