Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('wp-load.php');
- global $wpdb;
- $aUsers = $wpdb->get_results("SELECT user_id,meta_value FROM $wpdb->usermeta WHERE meta_key = 'bb_favorites'");
- $i = 0;
- foreach($aUsers as $user){
- $i++;
- $sTopics = $user->meta_value;
- $aTopics = explode(',',$sTopics);
- $sUser_name = $wpdb->get_col("SELECT user_login FROM $wpdb->users WHERE ID=$user->user_id");
- echo "USER: ".$sUser_name[0]." (".$user->user_id.")</br>";
- $sSubscriptions = "";
- foreach($aTopics as $sOld_topic_id){
- echo "Old topic id :".$sOld_topic_id."</br>";
- if(strlen($sOld_topic_id)>0){
- $sTopic_id = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_value = $sOld_topic_id AND meta_key='_bbp_old_topic_id'");
- $sSubscriptions .= $sTopic_id[0].",";
- }
- }
- $sSubscriptions = trim($sSubscriptions,",");
- echo "NEW SUBSCRIPTIONS: ".$sSubscriptions."</br>";
- $res = add_user_meta($user->user_id, "wp__bbp_subscriptions", $sSubscriptions );
- if($res == false){
- echo "META KEY WASN'T INSRETED!</br>";
- } else{
- echo "META KEY WAS INSERTED!</br>";
- }
- }
- echo "SUBSCRIPTIONS FOR $i USERS WERE UPDATED FROM bb_favorites TO wp__bbp_subscriptions</br>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement