WP Cron: Save third party data as user meta

An alternative way to do what I wanted : Save the time when the action has been ran and check the difference with actual time : function my_save_statistiques( $user_id ) { $user_id = get_current_user_id(); $current_time = time(); if (empty($current_time)) { update_usermeta( $user_id, ‘last_analytics’, $current_time ); } $last_analytics = get_user_meta( $user_id, ‘last_analytics’, true ); $diff = … Read more

Store Foreach in user profile

Your problem is here: $my_graph =. At every iteration you are resetting the entire string to a new value. You need $my_graph .= — notice the .— to concatenate a string together. That is a PHP syntax problem. I don’t think I would do it this way though. update_usermeta() will serialize an array or object … Read more

If logged in user meta is

No, not correct – get_user_meta() returns meta data based on the $user_id parameter you provide. You can combine it with get_current_user_id() to check if an user is logged in and than – if so – get the post meta. E.g. like this: $curr_user_id = get_current_user_id(); // the value is 0 if the user isn’t logged-in … Read more

Get currentuserinfo firstname and lastname

You are using get_currentuserinfo in a wrong way because you are passing parameters that this functions doesn’t accept and you expect that the functions return directly what you want. get_currentuserinfo doesn’t accept any parameter, returns a WP User object and require the global $current_user var. Anyway, I prefer to use wp_get_current_user() in order to avoid … Read more

Fetch User Meta Data

All of this can be done using WP_User_Query: $users = new WP_User_Query(array( meta_query( array( ‘key’ => ‘login_status’, ‘value’ => ‘0’ ), array( ‘key’ => ‘active_code’, ‘value’ => ‘3f7431e226893f16cbe44424850d00ad’ ) ) )); This will return a list of users that meet your requirements. Then you can get the ids like so: $user_ids = wp_list_pluck( $users->get_results(), ‘ID’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)