From 50be2467fd1c926bdcb3adb0070d40474266ffc2 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 8 Aug 2012 11:12:08 +0000 Subject: [PATCH] =?UTF-8?q?-=20Cuando=20la=20dedicatoria=20se=20dedica=20a?= =?UTF-8?q?=20un=20usuario=20no=20registrado,=20tiene=20que=20pedir=20el?= =?UTF-8?q?=20pa=C3=ADs=20del=20usuario=20y=20mostrarlo=20todo=20en=20la?= =?UTF-8?q?=20dedicatoria.=20-=20Cuando=20el=20usuario=20se=20registra,=20?= =?UTF-8?q?se=20asocian=20las=20dedicatorias=20con=20email=20al=20nuevos?= =?UTF-8?q?=20usuario.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.ASong2U_Web/trunk@75 cd1a4ea2-8c7f-e448-aada-19d1fee9e1d6 --- .../bp-dedication-create-dedication.php | 3 +- wp-content/themes/score/functions.php | 47 ++++++++++++++----- .../themes/score/loop-dedication-data.php | 3 +- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php index 94a37cd..4beb869 100644 --- a/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php +++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php @@ -123,8 +123,7 @@ function bp_dedication_create_new_dedication() { if (count($friend_ids) > 1) { $friend_info = get_userdata($friend_ids[1]); add_post_meta($post_id, 'ghostpool_destination_user_id', $friend_info->ID); - add_post_meta($post_id, 'ghostpool_destination_user_name', $friend_info->user_login); - add_post_meta($post_id, 'ghostpool_destination_user_email', $friend_info->user_email); + add_post_meta($post_id, 'ghostpool_destination_user_name', $friend_info->user_login); } if (isset($friend_email) && (is_email($friend_email))) { diff --git a/wp-content/themes/score/functions.php b/wp-content/themes/score/functions.php index ac00c77..15dfeb9 100644 --- a/wp-content/themes/score/functions.php +++ b/wp-content/themes/score/functions.php @@ -107,7 +107,7 @@ function gp_get_flag_img_country($country_name = '', $flagsize=32) { } else { $src .= 'none.png'; } - return '' . $country_code . ''; + return '' . $country_name . ''; } @@ -710,16 +710,41 @@ add_action('wp', 'gp_encoded_dedication_redirect_for_users', 2); -function asociate_dedications_to_new_user($user_id) { -/* if (!current_user_can('edit_user', $user_id)) { - return false; - } - update_user_meta($user_id, 'address', $_POST['address']); - update_user_meta($user_id, 'city', $_POST['city']); - update_user_meta($user_id, 'province', $_POST['province']); - update_user_meta($user_id, 'postalcode', $_POST['postalcode']);*/ -} +function asociate_dedications_to_new_user($user_id) { + global $post; + $user = get_user_by('id', $user_id); + + $category_name = 'dedication'; + $post_status = array('publish', 'private'); + + _log('Email del usuario => ' . $user->user_email); + + $args = array( + 'post_type' => array('post'), + 'posts_per_page' => -1, + 'post_status' => $post_status, + 'category_name' => $category_name, + 'meta_key' => 'ghostpool_destination_user_email', + 'meta_value' => $user->user_email + ); + + $emailPosts = new WP_Query($args); + + while ($emailPosts->have_posts()) { + $emailPosts->the_post(); + + if (!update_post_meta(get_the_ID(), 'ghostpool_destination_user_id', $user_id)) + add_post_meta(get_the_ID(), 'ghostpool_destination_user_id', $user_id, true); + if (!update_post_meta(get_the_ID(), 'ghostpool_destination_user_name', $user->user_login)) + add_post_meta(get_the_ID(), 'ghostpool_destination_user_name', $user->user_login, true); + + delete_post_meta(get_the_ID(), 'ghostpool_destination_user_email'); + delete_post_meta(get_the_ID(), 'ghostpool_destination_user_country'); + + } + wp_reset_postdata(); +} +add_action( 'user_register', 'asociate_dedications_to_new_user'); -//add_action( 'edit_user_profile_update', 'asociate_dedications_to_new_user' ); ?> \ No newline at end of file diff --git a/wp-content/themes/score/loop-dedication-data.php b/wp-content/themes/score/loop-dedication-data.php index d6cccc9..1f5e31d 100644 --- a/wp-content/themes/score/loop-dedication-data.php +++ b/wp-content/themes/score/loop-dedication-data.php @@ -38,8 +38,7 @@ $gp_settings['from_flag'] = gp_get_the_flag($gp_settings['from_user_id']); $gp_settings['to_user_id'] = get_post_meta($post->ID, 'ghostpool_destination_user_id', true); $gp_settings['to_user_email'] = get_post_meta($post->ID, 'ghostpool_destination_user_email', true); $gp_settings['to_user_country'] = get_post_meta($post->ID, 'ghostpool_destination_user_country', true); -$gp_settings['to_user'] = get_user_by ('id', $gp_settings['to_user_id']); - +$gp_settings['to_user'] = get_userdata($gp_settings['to_user_id']); if ($gp_settings['to_user']) { $gp_settings['to_flag'] = gp_get_the_flag($gp_settings['to_user']->ID, 24);