Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291621

Token is not being updated when site is refreshed

$
0
0

I expect a token to get the latest value from the database.
However, using the following code, in this case, the value of $points will not change when the site is being refreshed. (Cache is not enabled)

//Get data:
global $user;
$user_fields = user_load($user->uid);

$data = array('node' => $node);


//Token replace:
$points = token_replace('[current-user:field_points]', $data);
$userid = token_replace('[current-user:uid]', $data);

//generation of random number:
$points_new = mt_rand(0, 999);

//Output:
print $points . '<br>';
print $points_new . '<br>';

//Update Field with random number:  
db_update('field_data_field_points')
->expression('field_points_value', ':field_points_value', array(':field_points_value' => $points_new))
->condition('entity_id', $userid)
->execute();

Viewing all articles
Browse latest Browse all 291621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>