· 10 years ago · Jan 14, 2016, 02:18 PM
1<?php
2
3/********************** COMMENTS ********************
4 *
5 * FunctionName: bp_is_home()
6 * Description:
7 * SourceFile: ../bp-core/deprecated/1.5.php.
8 * ChangeLog: Replace the 'bp_is_home()' statement and codeblock with the modified code block.
9 *
10 */
11
12function bp_is_home() {
13 _deprecated_function( __FUNCTION__, '1.5', 'bp_is_my_profile' );
14 // return bp_is_my_profile();
15}
16
17
18*************************************************************************************************************************************
19*************************************************************************************************************************************
20*************************************************************************************************************************************
21*************************************************************************************************************************************
22*************************************************************************************************************************************
23
24
25/********************** COMMENTS ********************
26 *
27 * FunctionName: bp_core_fetch_avatar()
28 * Description: Get an avatar for a BuddyPress object.
29 * SourceFile: ../bp-core/bp-core-avatars.php.
30 * ChangeLog: Replace the 'bp_core_fetch_avatar()' statement and codeblock with the modified code block.
31 *
32 */
33
34function bp_core_fetch_avatar( $args = '' ) {
35 global $bp, $current_blog;
36
37 // Set a few default variables
38 $def_object = 'user';
39 $def_type = 'thumb';
40 $def_class = 'avatar';
41 $def_alt = __( 'Avatar Image', 'buddypress' );
42
43 // Set the default variables array
44 $defaults = array(
45 'item_id' => false,
46 'object' => $def_object, // user/group/blog/custom type (if you use filters)
47 'type' => $def_type, // thumb or full
48 'avatar_dir' => false, // Specify a custom avatar directory for your object
49 'width' => false, // Custom width (int)
50 'height' => false, // Custom height (int)
51 'class' => $def_class, // Custom <img> class (string)
52 'css_id' => false, // Custom <img> ID (string)
53 'alt' => $def_alt, // Custom <img> alt (string)
54 'email' => false, // Pass the user email (for gravatar) to prevent querying the DB for it
55 'no_grav' => false, // If there is no avatar found, return false instead of a grav?
56 'html' => true, // Wrap the return img URL in <img />
57 'title' => '' // Custom <img> title (string)
58 );
59
60 // Compare defaults to passed and extract
61 $params = wp_parse_args( $args, $defaults );
62 extract( $params, EXTR_SKIP );
63
64 // Set item_id if not passed
65 if ( !$item_id ) {
66 if ( 'user' == $object )
67 $item_id = $bp->displayed_user->id;
68 else if ( bp_is_active( 'groups' ) && 'group' == $object )
69 $item_id = $bp->groups->current_group->id;
70 else if ( 'blog' == $object )
71 $item_id = $current_blog->id;
72
73 $item_id = apply_filters( 'bp_core_avatar_item_id', $item_id, $object );
74
75 if ( !$item_id )
76 return false;
77 }
78
79 // Set avatar_dir if not passed (uses $object)
80 if ( !$avatar_dir ) {
81 if ( 'user' == $object )
82 $avatar_dir = 'avatars';
83 else if ( bp_is_active( 'groups' ) && 'group' == $object )
84 $avatar_dir = 'group-avatars';
85 else if ( 'blog' == $object )
86 $avatar_dir = 'blog-avatars';
87
88 $avatar_dir = apply_filters( 'bp_core_avatar_dir', $avatar_dir, $object );
89
90 if ( !$avatar_dir )
91 return false;
92 }
93
94 // Add an identifying class to each item
95 $class .= ' ' . $object . '-' . $item_id . '-avatar';
96
97 // Get item name for alt/title tags
98 $item_name = '';
99
100 if ( 'user' == $object )
101 $item_name = bp_core_get_user_displayname( $item_id );
102 elseif ( 'group' == $object )
103 $item_name = bp_get_group_name( new BP_Groups_Group( $item_id ) );
104 elseif ( 'blog' == $object )
105 $item_name = get_blog_option( $item_id, 'blogname' );
106
107 $alt = sprintf( $alt, apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) );
108
109 // Set title tag
110 if ( $title )
111 $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $title, $item_id, $object ) ) . "'";
112 elseif ( $item_name )
113 $title = " title='" . esc_attr( apply_filters( 'bp_core_avatar_title', $item_name, $item_id, $object ) ) . "'";
114
115 // Set CSS ID if passed
116 if ( !empty( $css_id ) )
117 $css_id = " id='{$css_id}'";
118
119 // Set avatar width
120 if ( $width )
121 $html_width = " width='{$width}'";
122 else
123 $html_width = ( 'thumb' == $type ) ? ' width="' . bp_core_avatar_thumb_width() . '"' : ' width="' . bp_core_avatar_full_width() . '"';
124
125 // Set avatar height
126 if ( $height )
127 $html_height = " height='{$height}'";
128 else
129 $html_height = ( 'thumb' == $type ) ? ' height="' . bp_core_avatar_thumb_height() . '"' : ' height="' . bp_core_avatar_full_height() . '"';
130
131}
132
133
134*************************************************************************************************************************************
135*************************************************************************************************************************************
136*************************************************************************************************************************************
137*************************************************************************************************************************************
138*************************************************************************************************************************************
139
140
141/********************** COMMENTS ********************
142 *
143 * FunctionName: public static function core_custom_search()
144 * Description: Set up a customized search.
145 * SourceFile: ../bp-core/classes/class-bp-core-user.php.
146 * ChangeLog: Add the 'public static function core_custom_search()' statement and codeblock.
147 *
148 */
149
150/** Static Functions ******************************************************/
151
152public static function core_custom_search()
153 {
154 global $wpdb, $bp;
155 if (isset($_POST["members_search_submit"]))
156 {
157 $result = $wpdb->get_results("SELECT * FROM $wpdb->users");
158 foreach ($get_results as $user)
159 {
160 $member_number = $user->ID;
161 $member_first_name = "";
162 $partner_first_name = "";
163 $street_address = "";
164 $city = "";
165 $email1 = "";
166 $email2 = "";
167 $member_type = "";
168 $member_last_name = "";
169 $partner_last_name = "";
170 $street_address2 = "";
171 $state = "";
172 $code = "";
173 $country = "";
174 $phone1 = "";
175 $phone2 = "";
176 $camper_year = "";
177 $camper_make = "";
178 $camper_model = "";
179 $in_member_profile = "";
180 $is_show_member_profile = "";
181 $word_in_request = "";
182 $word_in_admin_comment = "";
183 $region_ec = "";
184 $region_nr = "";
185 $region_ma = "";
186 $region_sc = "";
187 $region_fl = "";
188 $region_gl = "";
189 $region_scen = "";
190 $region_up = "";
191 $region_kat = "";
192 $region_pn = "";
193 $region_s = "";
194 $region_hi = "";
195 $renew_date_from = "";
196 $renew_date_to = "";
197 $change_date_from = "";
198 $change_date_to = "";
199 $join_date_from = "";
200 $join_date_to = "";
201 $expire_date_from = "";
202 $expire_date_to = "";
203 $is_expired = "";
204 }
205 }
206 }
207
208*************************************************************************************************************************************
209
210/********************** COMMENTS ********************
211 *
212 * FunctionName: public static function get_users()
213 * Description: Get a list of users that match the query parameters.
214 * SourceFile: ../bp-core/classes/class-bp-core-user.php.
215 * ChangeLog: Replace the 'public static function get_users()' statement and codeblock with the modified code block.
216 *
217 */
218
219public static function get_users( $type, $limit = 0, $page = 1, $user_id = 0, $include = false, $search_terms = false, $populate_extras = true, $exclude = false, $meta_key = false, $meta_value = false ) {
220 global $wpdb, $bp;
221
222 if (isset($_REQUEST["only_search_result"]) == FALSE)
223 return;
224 $type = "alphabetical";
225
226 $sql = array();
227
228 $sql['select_main'] = "SELECT DISTINCT u.ID as id, u.user_registered, u.user_nicename, u.user_login, u.display_name, u.user_email";
229
230 if ( 'active' == $type || 'online' == $type || 'newest' == $type )
231 $sql['select_active'] = ", um.meta_value as last_activity";
232
233 if ( 'popular' == $type )
234 $sql['select_popular'] = ", um.meta_value as total_friend_count";
235
236 if ( 'alphabetical' == $type )
237 $sql['select_alpha'] = ", pd.value as fullname";
238
239 if ( $meta_key ) {
240 $sql['select_meta'] = ", umm.meta_key";
241
242 if ( $meta_value )
243 $sql['select_meta'] .= ", umm.meta_value";
244 }
245
246 $sql['from'] = "FROM $wpdb->users u LEFT JOIN $wpdb->usermeta um ON um.user_id = u.ID";
247
248 // We search against xprofile fields, so we must join the table
249 if ( $search_terms && bp_is_active( 'xprofile' ) )
250 $sql['join_profiledata_search'] = "LEFT JOIN {$bp->profile->table_name_data} spd ON u.ID = spd.user_id";
251
252 // Alphabetical sorting is done by the xprofile Full Name field
253 if ( 'alphabetical' == $type )
254 $sql['join_profiledata_alpha'] = "LEFT JOIN {$bp->profile->table_name_data} pd ON u.ID = pd.user_id";
255
256 if ( $meta_key )
257 $sql['join_meta'] = "LEFT JOIN {$wpdb->usermeta} umm ON umm.user_id = u.ID";
258
259 $sql['where'] = 'WHERE ' . bp_core_get_status_sql( 'u.' );
260
261 if ( 'active' == $type || 'online' == $type || 'newest' == $type )
262 $sql['where_active'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'last_activity' ) );
263
264 if ( 'popular' == $type )
265 $sql['where_popular'] = $wpdb->prepare( "AND um.meta_key = %s", bp_get_user_meta_key( 'total_friend_count' ) );
266
267 if ( 'online' == $type )
268 $sql['where_online'] = "AND DATE_ADD( um.meta_value, INTERVAL 5 MINUTE ) >= UTC_TIMESTAMP()";
269
270 if ( 'alphabetical' == $type )
271 $sql['where_alpha'] = "AND pd.field_id = 179";
272
273 if ( !empty( $exclude ) )
274 $sql['where_exclude'] = "AND u.ID NOT IN ({$exclude})";
275
276 if ( $include ) {
277 if ( is_array( $include ) )
278 $uids = $wpdb->escape( implode( ',', (array)$include ) );
279 else
280 $uids = $wpdb->escape( $include );
281
282 if ( !empty( $uids ) )
283 $sql['where_users'] = "AND u.ID IN ({$uids})";
284 }
285
286 else if ( $user_id && bp_is_active( 'friends' ) ) {
287 $friend_ids = friends_get_friend_user_ids( $user_id );
288 $friend_ids = $wpdb->escape( implode( ',', (array)$friend_ids ) );
289
290 if ( !empty( $friend_ids ) )
291 $sql['where_friends'] = "AND u.ID IN ({$friend_ids})";
292
293 // User has no friends, return false since there will be no users to fetch.
294 else
295 return false;
296
297 }
298
299 //if ($uids != "")
300 //print( '<input type="hidden" value="'.str_replace(",","|",$uids).'" name="user_id_list"/>');
301 //do_action( 'print_all_searching_users', $uids );
302
303 if ( $search_terms && bp_is_active( 'xprofile' ) ) {
304 $search_terms = like_escape( $wpdb->escape( $search_terms ) );
305 $sql['where_searchterms'] = "AND spd.value LIKE '%%$search_terms%%'";
306 }
307
308 if ( $meta_key ) {
309 $sql['where_meta'] = $wpdb->prepare( " AND umm.meta_key = %s", $meta_key );
310
311 // If a meta value is provided, match it
312 if ( $meta_value ) {
313 $sql['where_meta'] .= $wpdb->prepare( " AND umm.meta_value = %s", $meta_value );
314 }
315 }
316
317 switch ( $type ) {
318 case 'active': case 'online': default:
319 $sql[] = "ORDER BY um.meta_value DESC";
320 break;
321 case 'newest':
322 $sql[] = "ORDER BY u.ID DESC";
323 break;
324 case 'alphabetical':
325 $sql[] = "ORDER BY pd.value ASC, display_name ASC";
326 break;
327 case 'random':
328 $sql[] = "ORDER BY rand()";
329 break;
330 case 'popular':
331 $sql[] = "ORDER BY CONVERT(um.meta_value, SIGNED) DESC";
332 break;
333 }
334
335 $user_list = array();
336 $data = $wpdb->get_results(join( ' ', (array)$sql ));
337 foreach ($data as $u)
338 {
339 $user_list[] = $u->id;
340 }
341 //echo join( ' ', (array)$sql );exit;
342 //print_r($user_list);exit;
343 if ($user_list != "")
344 print( '<input type="hidden" value="'.implode("|",$user_list).'" name="user_id_list"/>');
345
346 //echo join( ' ', (array)$sql );exit;
347 //echo "$limit && $page";
348 if ( $limit && $page )
349 $sql['pagination'] = $wpdb->prepare( "LIMIT %d, %d", intval( ( $page - 1 ) * $limit), intval( $limit ) );
350
351 // Get paginated results
352 $paged_users_sql = apply_filters( 'bp_core_get_paged_users_sql', join( ' ', (array)$sql ), $sql );
353 $paged_users = $wpdb->get_results( $paged_users_sql );
354
355 //print_r($paged_users_sql);exit;
356
357 // Re-jig the SQL so we can get the total user count
358 unset( $sql['select_main'] );
359
360 if ( !empty( $sql['select_active'] ) )
361 unset( $sql['select_active'] );
362
363 if ( !empty( $sql['select_popular'] ) )
364 unset( $sql['select_popular'] );
365
366 if ( !empty( $sql['select_alpha'] ) )
367 unset( $sql['select_alpha'] );
368
369 if ( !empty( $sql['pagination'] ) )
370 unset( $sql['pagination'] );
371
372 array_unshift( $sql, "SELECT COUNT(DISTINCT u.ID)" );
373 //echo $paged_users_sql;
374 // Get total user results
375 $total_users_sql = apply_filters( 'bp_core_get_total_users_sql', join( ' ', (array)$sql ), $sql );
376 $total_users = $wpdb->get_var( $total_users_sql );
377
378 /***
379 * Lets fetch some other useful data in a separate queries, this will be faster than querying the data for every user in a list.
380 * We can't add these to the main query above since only users who have this information will be returned (since the much of the data is in usermeta and won't support any type of directional join)
381 */
382 if ( !empty( $populate_extras ) ) {
383 $user_ids = array();
384
385 foreach ( (array)$paged_users as $user )
386 $user_ids[] = $user->id;
387
388 $user_ids = $wpdb->escape( join( ',', (array)$user_ids ) );
389
390 // Add additional data to the returned results
391 $paged_users = BP_Core_User::get_user_extras( $paged_users, $user_ids, $type );
392 }
393
394 return array( 'users' => $paged_users, 'total' => $total_users );
395 }
396
397*************************************************************************************************************************************
398*************************************************************************************************************************************
399*************************************************************************************************************************************
400*************************************************************************************************************************************
401*************************************************************************************************************************************
402
403/********************** COMMENTS ********************
404 *
405 * FunctionName: bp_core_get_last_activity()
406 * Description: Format last activity string based on time since date given.
407 * SourceFile: ../bp-core/bp-core-functions.php.
408 * ChangeLog: Replace the 'bp_core_get_last_activity()' statement and codeblock with the modified code block.
409 *
410 */
411
412function bp_core_get_last_activity( $last_activity_date, $string ) {
413/* if ( !$last_activity_date || empty( $last_activity_date ) )
414 $last_active = __( 'not recently active', 'buddypress' );
415 else
416 $last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
417
418 return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );*/
419}
420
421
422*************************************************************************************************************************************
423*************************************************************************************************************************************
424*************************************************************************************************************************************
425*************************************************************************************************************************************
426*************************************************************************************************************************************
427
428/********************** COMMENTS ********************
429 *
430 * FunctionName: bp_get_options_nav()
431 * Description: Output the "options nav", the secondary-level single item navigation menu.
432 * SourceFile: ../bp-core/bp-core-template.php.
433 * ChangeLog: Replace the 'bp_get_options_nav()' statement and codeblock with the modified code block.
434 *
435 */
436
437function bp_get_options_nav() {
438 global $bp;
439
440 // If we are looking at a member profile, then the we can use the current component as an
441 // index. Otherwise we need to use the component's root_slug
442 $component_index = !empty( $bp->displayed_user ) ? $bp->current_component : bp_get_root_slug( $bp->current_component );
443
444 if ( !bp_is_single_item() ) {
445 if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) {
446 return false;
447 } else {
448 $the_index = $component_index;
449 }
450 } else {
451 if ( !isset( $bp->bp_options_nav[$bp->current_item] ) || count( $bp->bp_options_nav[$bp->current_item] ) < 1 ) {
452 return false;
453 } else {
454 $the_index = $bp->current_item;
455 }
456 }
457
458 // Loop through each navigation item
459 foreach ( (array)$bp->bp_options_nav[$the_index] as $subnav_item ) {
460 if ( !$subnav_item['user_has_access'] )
461 continue;
462 if ($subnav_item['name'] == "Change Avatar")
463 continue;
464 // If the current action or an action variable matches the nav item id, then add a highlight CSS class.
465 if ( $subnav_item['slug'] == $bp->current_action ) {
466 $selected = ' class="current selected"';
467 } else {
468 $selected = '';
469 }
470
471 // List type depends on our current component
472 $list_type = bp_is_group() ? 'groups' : 'personal';
473
474 // echo out the final list item
475 echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-' . $list_type . '-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );
476 }
477}
478
479function bp_get_options_nav_for_current_user() {
480 global $bp;
481
482 echo '<div id="subnav" class="item-list-tabs no-ajax">
483 <ul>
484 <li id="public-personal-li"><a href="'.$bp->displayed_user->domain.'profile/public/" id="public">Public</a></li><li id="edit-personal-li"><a href="'.$bp->displayed_user->domain.'profile/edit/" id="edit">Edit</a></li></ul>
485 </div>';
486}
487
488function bp_get_options_title() {
489 global $bp;
490
491 if ( empty( $bp->bp_options_title ) )
492 $bp->bp_options_title = __( 'Options', 'buddypress' );
493
494 echo apply_filters( 'bp_get_options_title', esc_attr( $bp->bp_options_title ) );
495}
496
497
498*************************************************************************************************************************************
499*************************************************************************************************************************************
500*************************************************************************************************************************************
501*************************************************************************************************************************************
502*************************************************************************************************************************************
503
504/********************** COMMENTS ********************
505 *
506 * FunctionName: wp_kses_bad_protocol_once2()
507 * Description: Callback for wp_kses_bad_protocol_once() regular expression. This function processes URL protocols, checks to see if they're in the whitelist or not, and returns different data depending on the answer.
508 * SourceFile: ../bp-forums/bbpress/bb-includes/backpress/functions.kses.php.
509 * ChangeLog: Replace the 'wp_kses_bad_protocol_once2()' statement and codeblock with the modified code block.
510 *
511 */
512
513function wp_kses_bad_protocol_once2( $string, $allowed_protocols ) {
514 $string2 = wp_kses_decode_entities($string);
515 $string2 = preg_replace('/\s/', '', $string2);
516 $string2 = wp_kses_no_null($string2);
517 $string2 = strtolower($string2);
518
519 $allowed = false;
520 foreach ( (array) $allowed_protocols as $one_protocol )
521 if ( strtolower($one_protocol) == $string2 ) {
522
523 break;
524 }
525
526 if ($allowed)
527 return "$string2:";
528 else
529 return '';
530}
531
532
533*************************************************************************************************************************************
534*************************************************************************************************************************************
535*************************************************************************************************************************************
536*************************************************************************************************************************************
537*************************************************************************************************************************************
538
539/********************** COMMENTS ********************
540 *
541 * FunctionName: bp_groups_pagination_count()
542 * Description: Output the "Viewing x-y of z groups" pagination message.
543 * SourceFile: ../bp-core/bp-groups-template.php.
544 * ChangeLog: Replace the 'bp_groups_pagination_count()' statement and codeblock with the modified code block.
545 *
546 */
547
548function bp_groups_pagination_count() {
549 echo bp_get_groups_pagination_count();
550}
551 function bp_get_groups_pagination_count() {
552 global $bp, $groups_template;
553
554 $start_num = intval( ( $groups_template->pag_page - 1 ) * $groups_template->pag_num ) + 1;
555 $from_num = bp_core_number_format( $start_num );
556 $to_num = bp_core_number_format( ( $start_num + ( $groups_template->pag_num - 1 ) > $groups_template->total_group_count ) ? $groups_template->total_group_count : $start_num + ( $groups_template->pag_num - 1 ) );
557 $total = bp_core_number_format( $groups_template->total_group_count );
558
559 return apply_filters( 'bp_get_groups_pagination_count', sprintf( __( 'Viewing group %1$s to %2$s of %3$s .', 'buddypress' ), $from_num, $to_num, $total ) );
560 }
561
562*************************************************************************************************************************************
563
564/********************** COMMENTS ********************
565 *
566 * FunctionName: bp_group_member_pagination_count()
567 * Description: Filters the HTML markup to be used for group member listing pagination.
568 * SourceFile: ../bp-core/bp-groups-template.php.
569 * ChangeLog: Replace the 'bp_group_member_pagination_count()' statement and codeblock with the modified code block.
570 *
571 */
572
573function bp_group_member_pagination_count() {
574 echo bp_get_group_member_pagination_count();
575}
576 function bp_get_group_member_pagination_count() {
577 global $members_template;
578
579 $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
580 $from_num = bp_core_number_format( $start_num );
581 $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
582 $total = bp_core_number_format( $members_template->total_member_count );
583
584 return apply_filters( 'bp_get_group_member_pagination_count', sprintf( __( 'Viewing members %1$s to %2$s of %3$s .', 'buddypress' ), $from_num, $to_num, $total ) );
585 }
586
587
588*************************************************************************************************************************************
589*************************************************************************************************************************************
590*************************************************************************************************************************************
591*************************************************************************************************************************************
592
593/********************** COMMENTS ********************
594 *
595 * FunctionName: bp_core_screen_signup()
596 * Description: Handle the loading of the signup screen.
597 * SourceFile: ../bp-core/bp-members-screens.php.
598 * ChangeLog: Replace the 'bp_core_screen_signup()' statement and codeblock with the modified code block.
599 *
600 */
601
602function bp_core_screen_signup() {
603 global $bp, $wpdb;
604
605 if ( !bp_is_current_component( 'register' ) )
606 return;
607
608 // Not a directory
609 bp_update_is_directory( false, 'register' );
610
611 // If the user is logged in, redirect away from here
612 if (!current_user_can(EZ_XPF_MD_MEMBER) && !current_user_can(EZ_XPF_ADMINISTRATOR))
613 {
614 if ( is_user_logged_in()) {
615 if ( bp_is_component_front_page( 'register' ) )
616 bp_core_redirect( bp_get_root_domain() . '/' . bp_get_members_root_slug() );
617 else
618 bp_core_redirect( bp_get_root_domain() );
619
620 return;
621 }
622 }
623
624 $bp->signup->step = 'request-details';
625
626 if ( !bp_get_signup_allowed() ) {
627 $bp->signup->step = 'registration-disabled';
628 }
629
630 // If the signup page is submitted, validate and save
631 elseif ( isset( $_POST['signup_submit'] ) ) {
632
633
634 $username = substr(strtolower($_POST["field_1"]),0,1) . strtolower($_POST["field_179"]);
635 $username = preg_replace('/[^a-zA-Z0-9]*/','',$username);
636 //var_dump($username);exit;
637 $user_count = "";
638 do
639 {
640 $row = $wpdb->get_row("SELECT * FROM wp_users WHERE user_login='".$username . $user_count."'");
641 if (!$row)
642 {
643 break;
644 }
645 else
646 {
647 if ($user_count == "")
648 $user_count = 1;
649 else
650 $user_count++;
651 }
652 }
653 while(true);
654
655 //get custom information from registration form
656 $username = $username . $user_count;
657 $_POST['signup_username'] = $username;
658 $_POST['signup_password'] = uniqid();
659 $_POST['signup_password_confirm'] = $_POST['signup_password'];
660 if ($_POST["field_1771"] != "")
661 $_POST['signup_email'] = $_POST["field_1771"];
662 else
663 $_POST['signup_email'] = $username . "@alinerownersclub.com";
664
665
666
667 //print_r($_POST);exit;
668 // Check the nonce
669 check_admin_referer( 'bp_new_signup' );
670
671 // Check the base account details for problems
672 $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );
673
674 //print_r($account_details);exit;
675
676 // If there are errors with account details, set them for display
677 if ( !empty( $account_details['errors']->errors['user_name'] ) )
678 $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
679
680 if ( !empty( $account_details['errors']->errors['user_email'] ) && !empty( $_POST['field_1771'] ) )
681 $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
682
683 // Check that both password fields are filled in
684 if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
685 $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' );
686
687 // Check that the passwords match
688 if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] )
689 $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' );
690
691 $bp->signup->username = $_POST['signup_username'];
692 $bp->signup->email = $_POST['signup_email'];
693
694
695 if (empty($_POST["field_1"]) || empty($_POST["field_179"]))
696 {
697 $bp->signup->errors['signup_username'] = "Please enter First and Last Name.";
698 }
699
700 // Now we've checked account details, we can check profile information
701 if ( bp_is_active( 'xprofile' ) ) {
702
703 // Make sure hidden field is passed and populated
704 if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) {
705
706 // Let's compact any profile field info into an array
707 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
708
709 // Loop through the posted fields formatting any datebox values then validate the field
710 foreach ( (array) $profile_field_ids as $field_id ) {
711 if ( !isset( $_POST['field_' . $field_id] ) ) {
712 if ( isset( $_POST['field_' . $field_id . '_day'] ) )
713 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ) );
714 }
715
716 // Create errors for required fields without values
717 if ($field_id == 3 ||
718 $field_id == 5 ||
719 $field_id == 6 ||
720 $field_id == 127 ||
721 $field_id == 126 ||
722 $field_id == 177)
723 continue;
724 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
725 $bp->signup->errors['field_' . $field_id] = __( 'This is a required field.', 'buddypress' );
726 }
727
728 // This situation doesn't naturally occur so bounce to website root
729 } else {
730 bp_core_redirect( bp_get_root_domain() );
731 }
732 }
733
734 if(!empty($_POST['field_177']) && !preg_match("/\d\d\d\.\d\d\d\.\d\d\d\d/i", $_POST['field_177']) ) {
735 $bp->signup->errors["field_177"] = 'Please enter a valid phone number!';
736 }
737 if(!empty($_POST['field_178']) && !preg_match("/\d\d\d\.\d\d\d\.\d\d\d\d/i", $_POST['field_178']) ) {
738 $bp->signup->errors["field_178"] = 'Please enter a valid phone number!';
739 }
740
741 if (!empty($_POST['field_1770']))
742 {
743 if ( !is_email( $_POST['field_1770'] ) )
744 $bp->signup->errors["field_1770"] = 'Please check your email address.';
745 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $_POST['field_1770'] ) )
746 $bp->signup->errors["field_1770"] = 'Please enter a valid email!';
747 }
748
749 //custom validations====================
750 if (!current_user_can(EZ_XPF_MD_MEMBER) && !current_user_can(EZ_XPF_ADMINISTRATOR))
751 {
752 if (empty($_POST['field_3']) || empty($_POST['field_5']) || empty($_POST['field_6']) || empty($_POST['field_126']) || empty($_POST['field_127']))
753 if (empty($_POST['field_177']))
754 $bp->signup->errors['field_3'] = "REQUIRED FIELDS:<br>Street, City, State, ZIP/Postal AND Country<br>
755 OR Phone Number<br>";
756 }
757 //end custom validations====================
758
759
760 // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled
761 if ( isset( $_POST['signup_with_blog'] ) ) {
762 $active_signup = $bp->site_options['registration'];
763
764 if ( 'blog' == $active_signup || 'all' == $active_signup ) {
765 $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );
766
767 // If there are errors with blog details, set them for display
768 if ( !empty( $blog_details['errors']->errors['blogname'] ) )
769 $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
770
771 if ( !empty( $blog_details['errors']->errors['blog_title'] ) )
772 $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0];
773 }
774 }
775
776 do_action( 'bp_signup_validate' );
777 //print_r($bp->signup->errors);
778 // Add any errors to the action for the field in the template for display.
779 if ( !empty( $bp->signup->errors ) ) {
780 foreach ( (array)$bp->signup->errors as $fieldname => $error_message )
781 add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">' . $error_message . '</div>" );' ) );
782 add_action( 'bp_signup_general_info_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">Please fill in all required fields, below.</div>" );' ) );
783 } else {
784 $bp->signup->step = 'save-details';
785
786 // No errors! Let's register those deets.
787 $active_signup = !empty( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : '';
788
789 if ( 'none' != $active_signup ) {
790
791 // Let's compact any profile field info into usermeta
792 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
793
794 // Loop through the posted fields formatting any datebox values then add to usermeta
795 foreach ( (array) $profile_field_ids as $field_id ) {
796 if ( !isset( $_POST['field_' . $field_id] ) ) {
797 if ( isset( $_POST['field_' . $field_id . '_day'] ) )
798 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] ) );
799 }
800
801 if ( !empty( $_POST['field_' . $field_id] ) )
802 $usermeta['field_' . $field_id] = $_POST['field_' . $field_id];
803 }
804
805 // Store the profile field ID's in usermeta
806 $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids'];
807
808 // Hash and store the password
809 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] );
810
811 // If the user decided to create a blog, save those details to usermeta
812 if ( 'blog' == $active_signup || 'all' == $active_signup )
813 $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false;
814
815 $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta );
816
817 // Finally, sign up the user and/or blog
818 if ( isset( $_POST['signup_with_blog'] ) && is_multisite() )
819 bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta );
820 else
821 {
822 $user_id = bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta );
823 do_action( 'bp_complete_signup_successful',$user_id );
824 }
825 $bp->signup->step = 'completed-confirmation';
826 }
827
828 do_action( 'bp_complete_signup' );
829 }
830
831 }
832
833 do_action( 'bp_core_screen_signup' );
834 bp_core_load_template( apply_filters( 'bp_core_template_register', 'registration/register' ) );
835}
836add_action( 'bp_screens', 'bp_core_screen_signup' );
837
838
839*************************************************************************************************************************************
840*************************************************************************************************************************************
841*************************************************************************************************************************************
842*************************************************************************************************************************************
843*************************************************************************************************************************************
844
845/********************** COMMENTS ********************
846 *
847 * FunctionName: bp_core_validate_user_signup()
848 * Description: Validate a user name and email address when creating a new user.
849 * SourceFile: ../bp-core/bp-members-template.php.
850 * ChangeLog: Replace the 'bp_core_validate_user_signup()' statement and codeblock with the modified code block.
851 *
852 */
853
854function bp_core_validate_user_signup( $user_name, $user_email ) {
855 global $wpdb;
856
857 $errors = new WP_Error();
858 $user_email = sanitize_email( $user_email );
859 //echo $user_email;exit;
860
861 if ( empty( $user_name ) )
862 $errors->add( 'user_name', __( '', 'buddypress' ) );
863
864 $maybe = array();
865 preg_match( "/[a-z0-9]+/", $user_name, $maybe );
866
867 // Make sure illegal names include BuddyPress slugs and values
868 bp_core_flush_illegal_names();
869
870 $illegal_names = get_site_option( 'illegal_names' );
871
872 if ( !validate_username( $user_name ) || in_array( $user_name, (array)$illegal_names ) || ( !empty( $maybe[0] ) && $user_name != $maybe[0] ) )
873 $errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) );
874
875 //if( strlen( $user_name ) < 4 )
876 //$errors->add( 'user_name', __( 'Username must be at least 4 characters', 'buddypress' ) );
877
878 if ( strpos( ' ' . $user_name, '_' ) != false )
879 $errors->add( 'user_name', __( 'Sorry, usernames may not contain the character "_"!', 'buddypress' ) );
880
881 // Is the user_name all numeric?
882 $match = array();
883 preg_match( '/[0-9]*/', $user_name, $match );
884
885 if ( $match[0] == $user_name )
886 $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!', 'buddypress' ) );
887
888 if ( !is_email( $user_email ) )
889 $errors->add( 'user_email', __( 'Please fill in a valid email address!', 'buddypress' ) );
890
891 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) )
892 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
893
894 $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' );
895
896 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
897 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
898
899 if ( in_array( $emaildomain, (array)$limited_email_domains ) == false )
900 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) );
901 }
902
903
904 // Check if the username has been used already.
905 if ( username_exists( $user_name ) )
906 $errors->add( 'user_name', __( 'Sorry, that username already exists!', 'buddypress' ) );
907
908 // Check if the email address has been used already.
909 if ( email_exists( $user_email ) )
910 $errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) );
911
912 $result = array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors );
913
914 // Apply WPMU legacy filter
915 $result = apply_filters( 'wpmu_validate_user_signup', $result );
916
917 return apply_filters( 'bp_core_validate_user_signup', $result );
918}
919
920*************************************************************************************************************************************
921
922/********************** COMMENTS ********************
923 *
924 * FunctionName: bp_core_signup_user()
925 * Description: Process data submitted at user registration and convert to a signup object.
926 * SourceFile: ../bp-core/bp-members-template.php.
927 * ChangeLog: Replace the 'bp_core_signup_user()' statement and codeblock with the modified code block.
928 *
929 */
930
931function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) {
932 global $bp, $wpdb;
933
934 // Multisite installs have their own install procedure
935 if ( is_multisite() ) {
936 wpmu_signup_user( $user_login, $user_email, $usermeta );
937
938 // On multisite, the user id is not created until the user activates the account
939 // but we need to cast $user_id to pass to the filters
940 $user_id = false;
941
942 } else {
943 $errors = new WP_Error();
944
945 $user_id = wp_insert_user( array(
946 'user_login' => $user_login,
947 'user_pass' => $user_password,
948 'display_name' => sanitize_title( $user_login ),
949 'user_email' => $user_email
950 ) );
951
952 if ( empty( $user_id ) ) {
953 $errors->add( 'registerfail', sprintf( __('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'buddypress' ), get_option( 'admin_email' ) ) );
954 return $errors;
955 }
956
957 $_SESSION["temp_password"] = $user_password;
958 $_SESSION["temp_registering_user_id"] = $user_id;
959
960 // Update the user status to '2' which we will use as 'not activated' (0 = active, 1 = spam, 2 = not active)
961 //$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 2 WHERE ID = %d", $user_id ) );
962 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 0 WHERE ID = %d", $user_id ) );//auto activate user
963
964 // Set any profile data
965 if ( bp_is_active( 'xprofile' ) ) {
966 if ( !empty( $usermeta['profile_field_ids'] ) ) {
967 $profile_field_ids = explode( ',', $usermeta['profile_field_ids'] );
968
969 foreach( (array)$profile_field_ids as $field_id ) {
970 if ( empty( $usermeta["field_{$field_id}"] ) )
971 continue;
972
973 $current_field = $usermeta["field_{$field_id}"];
974 xprofile_set_field_data( $field_id, $user_id, $current_field );
975 }
976 }
977 }
978 }
979 $bp->signup->username = $user_login;
980
981 /***
982 * Now generate an activation key and send an email to the user so they can activate their account
983 * and validate their email address. Multisite installs send their own email, so this is only for single blog installs.
984 *
985 * To disable sending activation emails you can user the filter 'bp_core_signup_send_activation_key' and return false.
986
987 if ( apply_filters( 'bp_core_signup_send_activation_key', true ) ) {
988 if ( !is_multisite() ) {
989 $activation_key = wp_hash( $user_id );
990 update_user_meta( $user_id, 'activation_key', $activation_key );
991 bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key ,$user_password,$user_login);
992 }
993 }*/
994
995 do_action( 'bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta );
996
997 return $user_id;
998}
999
1000*************************************************************************************************************************************
1001
1002
1003/********************** COMMENTS ********************
1004 *
1005 * FunctionName: bp_core_signup_send_validation_email()
1006 * Description: Send activation email to a newly registered user.
1007 * SourceFile: ../bp-core/bp-members-template.php.
1008 * ChangeLog: Replace the 'bp_core_signup_send_validation_email()' statement and codeblock with the modified code block.
1009 *
1010 */
1011
1012function bp_core_signup_send_validation_email( $user_id, $user_email, $key ,$password = "" ,$username = "",$message = "") {
1013 $activate_url = bp_get_activation_page() ."?key=$key";
1014 $activate_url = esc_url( $activate_url );
1015
1016 /*$message = 'Thank you for joining the Aliner Owners Club!<br>
1017 <br>
1018You are now able to log in using your username and temporary password as shown below. <br>
1019 <br>
1020Your username is: '.$username.'<br>
1021<br>
1022Your password is: '.$password.'<br>
1023<br>
1024Please click the following link to access the members-only pages of the website: <a href="http://alinerownersclub.org">http://alinerownersclub.org</a><br>
1025<br>
1026When you log on to the AOC Website, please go to the "Update or Renew Your Membership" option in Member Central and change your temporary password to something you can easily remember. ';*/
1027
1028 $subject = 'Thank You from the Aliner Owners Club';
1029
1030 // Send the message
1031 $to = apply_filters( 'bp_core_signup_send_validation_email_to', $user_email . ',', $user_id );
1032 $subject = apply_filters( 'bp_core_signup_send_validation_email_subject', $subject, $user_id );
1033 $message = apply_filters( 'bp_core_signup_send_validation_email_message', $message, $user_id, $activate_url );
1034 $headers = 'BCC: <new-member@alinerownersclub.org>' . "\r\n";
1035
1036 add_filter('wp_mail_content_type',create_function('', 'return "text/html";'));
1037 wp_mail( $to, $subject, $message, $headers );
1038
1039 do_action( 'bp_core_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key );
1040}
1041
1042*************************************************************************************************************************************
1043*************************************************************************************************************************************
1044*************************************************************************************************************************************
1045*************************************************************************************************************************************
1046*************************************************************************************************************************************
1047
1048/********************** COMMENTS ********************
1049 *
1050 * FunctionName: n/a
1051 * Description: Define the BP Default Component.
1052 * SourceFile: ../bp-core/bp-members-template.php.
1053 * ChangeLog: Add the statement to the top of the template file.
1054 *
1055 */
1056
1057define( 'BP_DEFAULT_COMPONENT', 'profile' );
1058
1059*************************************************************************************************************************************
1060
1061/********************** COMMENTS ********************
1062 *
1063 * FunctionName: bp_members_pagination_count()
1064 * Description: Output the members pagination count.
1065 * SourceFile: ../bp-core/bp-members-template.php.
1066 * ChangeLog: Replace the 'bp_members_pagination_count()' statement and codeblock with the modified code block.
1067 *
1068 */
1069
1070function bp_members_pagination_count() {
1071 echo bp_get_members_pagination_count();
1072}
1073 function bp_get_members_pagination_count() {
1074 global $bp, $members_template;
1075
1076 if ( empty( $members_template->type ) )
1077 $members_template->type = '';
1078
1079 $start_num = intval( ( $members_template->pag_page - 1 ) * $members_template->pag_num ) + 1;
1080 $from_num = bp_core_number_format( $start_num );
1081 $to_num = bp_core_number_format( ( $start_num + ( $members_template->pag_num - 1 ) > $members_template->total_member_count ) ? $members_template->total_member_count : $start_num + ( $members_template->pag_num - 1 ) );
1082 $total = bp_core_number_format( $members_template->total_member_count );
1083
1084 if ( 'active' == $members_template->type )
1085 $pag = sprintf( __( 'Viewing member %1$s to %2$s of %3$s', 'buddypress'), $from_num, $to_num, $total );
1086 else if ( 'popular' == $members_template->type )
1087 $pag = sprintf( __( 'Viewing member %1$s to %2$s of %3$s members with friends', 'buddypress' ), $from_num, $to_num, $total );
1088 else if ( 'online' == $members_template->type )
1089 $pag = sprintf( __( 'Viewing member %1$s to %2$s of %3$s members online.', 'buddypress' ), $from_num, $to_num, $total );
1090 else
1091 $pag = sprintf( __( 'Viewing member %1$s to %2$s of %3$s', 'buddypress' ), $from_num, $to_num, $total );
1092
1093 return apply_filters( 'bp_members_pagination_count', $pag );
1094 }
1095
1096*************************************************************************************************************************************
1097*************************************************************************************************************************************
1098*************************************************************************************************************************************
1099*************************************************************************************************************************************
1100*************************************************************************************************************************************
1101
1102/********************** COMMENTS ********************
1103 *
1104 * FunctionName: xprofile_sync_wp_profile()
1105 * Description: Syncs Xprofile data to the standard built in WordPress profile data.
1106 * SourceFile: ../bp-core/bp-xprofile-functions.php.
1107 * ChangeLog: Replace the 'xprofile_sync_wp_profile()' statement and codeblock with the modified code block.
1108 *
1109 */
1110
1111function xprofile_sync_wp_profile( $user_id = 0 ) {
1112 global $bp, $wpdb;
1113
1114 if ( !empty( $bp->site_options['bp-disable-profile-sync'] ) && (int)$bp->site_options['bp-disable-profile-sync'] )
1115 return true;
1116
1117 if ( empty( $user_id ) )
1118 $user_id = $bp->loggedin_user->id;
1119
1120 if ( empty( $user_id ) )
1121 return false;
1122
1123 $fullname = xprofile_get_field_data( bp_xprofile_fullname_field_name(), $user_id );
1124 $space = strpos( $fullname, ' ' );
1125
1126 if ( false === $space ) {
1127 $firstname = $fullname;
1128 $lastname = '';
1129 } else {
1130 $firstname = substr( $fullname, 0, $space );
1131 $lastname = trim( substr( $fullname, $space, strlen( $fullname ) ) );
1132 }
1133
1134 update_user_meta( $user_id, 'nickname', $fullname );
1135 update_user_meta( $user_id, 'first_name', $firstname );
1136 update_user_meta( $user_id, 'last_name', $lastname );
1137
1138 //var_dump($wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ));exit;
1139 //$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d", $fullname, $user_id ) );
1140}
1141add_action( 'xprofile_updated_profile', 'xprofile_sync_wp_profile' );
1142add_action( 'bp_core_signup_user', 'xprofile_sync_wp_profile' );
1143add_action( 'bp_core_activated_user', 'xprofile_sync_wp_profile' );
1144
1145
1146*************************************************************************************************************************************
1147*************************************************************************************************************************************
1148*************************************************************************************************************************************
1149*************************************************************************************************************************************
1150*************************************************************************************************************************************
1151
1152/********************** COMMENTS ********************
1153 *
1154 * FunctionName: function xprofile_screen_display_profile()
1155 * Description: Handles the display of the profile page by loading the correct template file.
1156 * SourceFile: ../bp-core/bp-xprofile-screens.php.
1157 * ChangeLog: Replace the 'function xprofile_screen_display_profile()' statement and codeblock with the modified code block.
1158 *
1159 */
1160
1161function xprofile_screen_display_profile() {
1162global $bp;
1163 bp_core_redirect( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1' );
1164
1165 $new = isset( $_GET['new'] ) ? $_GET['new'] : '';
1166
1167 do_action( 'xprofile_screen_display_profile', $new );
1168 bp_core_load_template( apply_filters( 'xprofile_template_display_profile', 'members/single/home' ) );
1169}
1170
1171*************************************************************************************************************************************
1172
1173/********************** COMMENTS ********************
1174 *
1175 * FunctionName: function xprofile_screen_edit_profile()
1176 * Description: Handles the display of the profile edit page by loading the correct template file.
1177 * SourceFile: ../bp-core/bp-xprofile-screens.php.
1178 * ChangeLog: Replace the 'function xprofile_screen_edit_profile()' statement and codeblock with the modified code block.
1179 *
1180 */
1181
1182function xprofile_screen_edit_profile() {
1183 global $bp,$wpdb;
1184
1185 if ( !bp_is_my_profile() && !is_super_admin() )
1186 return false;
1187
1188 // Make sure a group is set.
1189 if ( !bp_action_variable( 1 ) )
1190 bp_core_redirect( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1' );
1191
1192 // Check the field group exists
1193 if ( !bp_is_action_variable( 'group' ) || !xprofile_get_field_group( bp_action_variable( 1 ) ) ) {
1194 bp_do_404();
1195 return;
1196 }
1197
1198 // Check to see if any new information has been submitted
1199 if ( isset( $_POST['field_ids'] ) ) {
1200
1201 // Check the nonce
1202 check_admin_referer( 'bp_xprofile_edit' );
1203
1204 // Check we have field ID's
1205 if ( empty( $_POST['field_ids'] ) )
1206 bp_core_redirect( trailingslashit( $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . bp_action_variable( 1 ) ) );
1207
1208 // Explode the posted field IDs into an array so we know which
1209 // fields have been submitted
1210 $posted_field_ids = explode( ',', $_POST['field_ids'] );
1211 $is_required = array();
1212
1213 // Loop through the posted fields formatting any datebox values
1214 // then validate the field
1215 foreach ( (array)$posted_field_ids as $field_id ) {
1216 if ( !isset( $_POST['field_' . $field_id] ) ) {
1217
1218 if ( !empty( $_POST['field_' . $field_id . '_day'] ) && is_numeric( $_POST['field_' . $field_id . '_day'] ) ) {
1219 // Concatenate the values
1220 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
1221
1222 // Turn the concatenated value into a timestamp
1223 $_POST['field_' . $field_id] = date( 'Y-m-d H:i:s', strtotime( $date_value ) );
1224 }
1225
1226 }
1227
1228 // Create errors for required fields without values
1229 if ($field_id == 3 ||
1230 $field_id == 5 ||
1231 $field_id == 6 ||
1232 $field_id == 126 ||
1233 $field_id == 127 ||
1234 $field_id == 177)
1235 continue;
1236
1237
1238 $is_required[$field_id] = xprofile_check_is_required_field( $field_id );
1239 if ( $is_required[$field_id] && empty( $_POST['field_' . $field_id] ) )
1240 {
1241 add_action( 'bp_field_' . $field_id . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">This is a required field.</div>" );' ) );
1242 $errors = true;
1243 }
1244 }
1245
1246 $errorlist = array();
1247
1248 if(!empty($_POST['field_177']) && !preg_match("/\d\d\d\.\d\d\d\.\d\d\d\d/i", $_POST['field_177']) ) {
1249 $errorlist["field_177"] = 'Please enter a valid phone number!';
1250 }
1251 if(!empty($_POST['field_178']) && !preg_match("/\d\d\d\.\d\d\d\.\d\d\d\d/i", $_POST['field_178']) ) {
1252 $errorlist["field_178"] = 'Please enter a valid phone number!';
1253 }
1254
1255 if (!empty($_POST['field_1771']))
1256 {
1257 if ( !is_email( $_POST['field_1771'] ) )
1258 $errorlist["field_1771"] = 'Please check your email address.';
1259 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $_POST['field_1771'] ) )
1260 $errorlist["field_1771"] = 'Please enter a valid email!';
1261 }
1262
1263
1264 if (!empty($_POST['field_1770']))
1265 {
1266 if ( !is_email( $_POST['field_1770'] ) )
1267 $errorlist["field_1770"] = 'Please check your email address.';
1268 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $_POST['field_1770'] ) )
1269 $errorlist["field_1770"] = 'Please enter a valid email!';
1270 }
1271
1272 //custom validations====================
1273 if (!current_user_can(EZ_XPF_MD_MEMBER) && !current_user_can(EZ_XPF_ADMINISTRATOR))
1274 {
1275 if (empty($_POST['field_3']) || empty($_POST['field_5']) || empty($_POST['field_6']) || empty($_POST['field_126']) || empty($_POST['field_127']))
1276 if (empty($_POST['field_177']))
1277 $errorlist['field_3'] = "REQUIRED FIELDS:<br>Street, City, State, ZIP/Postal AND Country<br>
1278 OR Phone Number<br>";
1279 }
1280 //end custom validations====================
1281
1282 if ( !empty( $errorlist ) ) {
1283 foreach ( (array)$errorlist as $fieldname => $error_message )
1284 add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">' . $error_message . '</div>" );' ) );
1285 $errors = true;
1286 }
1287
1288 // There are errors
1289 if ( !empty( $errors ) ) {
1290 bp_core_add_message( __( 'Please fill in all the required fields, below.', 'buddypress' ), 'error' );
1291
1292 // No errors
1293 } else {
1294 // Reset the errors var
1295 $errors = false;
1296
1297 // Now we've checked for required fields, lets save the values.
1298 foreach ( (array)$posted_field_ids as $field_id ) {
1299
1300 // Certain types of fields (checkboxes, multiselects) may come through empty. Save them as an empty array so that they don't get overwritten by the default on the next edit.
1301 if ( empty( $_POST['field_' . $field_id] ) )
1302 $value = array();
1303 else
1304 $value = $_POST['field_' . $field_id];
1305
1306 if ($field_id == 1)
1307 continue;
1308
1309 if ($field_id == EZ_XPF_EMAIL)
1310 {
1311 if ($_POST['field_' . $field_id] != "")
1312 {
1313 $user_count = $wpdb->get_var("SELECT COUNT(*) FROM wp_users WHERE user_email='".$_POST['field_' . $field_id]."' AND `ID` <> '".$bp->displayed_user->id."'");
1314 //var_dump($user_count);exit;
1315 if ($user_count > 0)
1316 {
1317 $errors = 4;
1318 break;
1319 }
1320 }
1321 }
1322
1323 $update_result = xprofile_set_field_data( $field_id, $bp->displayed_user->id, $value, $is_required[$field_id] );
1324 if ( !$update_result )
1325 {
1326 $errors = true;
1327 }
1328 else
1329 do_action( 'xprofile_profile_field_data_updated', $field_id, $value );
1330 }
1331
1332 do_action( 'xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors );
1333
1334
1335 // Set the feedback messages
1336 if ( $errors == true)
1337 bp_core_add_message( __( 'There was a problem updating some of your profile information, please try again.', 'buddypress' ), 'error' );
1338 elseif ( $errors == 4)
1339 bp_core_add_message( "First and Second email address are duplicates. Please re-enter", 'error' );
1340 else
1341 bp_core_add_message( __( 'Changes saved.', 'buddypress' ) );
1342
1343
1344 // Redirect back to the edit screen to display the updates and message
1345 bp_core_redirect( trailingslashit( bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable( 1 ) ) );
1346 }
1347 }
1348
1349 do_action( 'xprofile_screen_edit_profile' );
1350 bp_core_load_template( apply_filters( 'xprofile_template_edit_profile', 'members/single/home' ) );
1351}
1352
1353
1354*************************************************************************************************************************************
1355*************************************************************************************************************************************
1356*************************************************************************************************************************************
1357*************************************************************************************************************************************
1358*************************************************************************************************************************************
1359
1360/********************** COMMENTS ********************
1361 *
1362 * FunctionName: function bp_the_profile_field_is_required()
1363 * Description: In some cases, the $field global is not an instantiation of the BP_XProfile_Field class. However, we have to make sure that all data originally in $field gets merged back in, after reinstantiation.
1364 * SourceFile: ../bp-core/bp-xprofile-template.php.
1365 * ChangeLog: Replace the 'function bp_the_profile_field_is_required()' statement and codeblock with the modified code block.
1366 *
1367 */
1368
1369function bp_the_profile_field_is_required() {
1370 echo bp_get_the_profile_field_is_required();
1371}
1372 function bp_get_the_profile_field_is_required() {
1373 global $field;
1374
1375 // Define locale variable(s)
1376 $retval = false;
1377
1378 // Super admins can skip required check
1379 //if ( is_super_admin() && !is_admin() )
1380
1381 if ((current_user_can(EZ_XPF_MD_MEMBER) || current_user_can(EZ_XPF_ADMINISTRATOR)) && $field->id != EZ_XPF_FIRSTNAME && $field->id != EZ_XPF_LASTNAME)
1382 $retval = false;
1383
1384 // All other users will use the field's setting
1385 else
1386 if ( isset( $field->is_required ) )
1387 $retval = $field->is_required;
1388
1389 return apply_filters( 'bp_get_the_profile_field_is_required', (bool) $retval );
1390 }
1391
1392 function bp_get_the_profile_field_is_required2() {
1393 global $field;
1394
1395 // Define locale variable(s)
1396 $retval = false;
1397
1398 // Super admins can skip required check
1399 //if ( is_super_admin() && !is_admin() )
1400
1401
1402 if ( isset( $field->is_required ) )
1403 $retval = $field->is_required;
1404
1405 return apply_filters( 'bp_get_the_profile_field_is_required', (bool) $retval );
1406 }
1407
1408*************************************************************************************************************************************
1409
1410/********************** COMMENTS ********************
1411 *
1412 * FunctionName: function get_showing_search_result(), function get_showing_search_result_current_user(), function get_showing_search_result_current_user_from_tpl()
1413 * Description: Adds custom search result functions.
1414 * SourceFile: ../bp-core/bp-xprofile-template.php.
1415 * ChangeLog: Add the following functions to the bp-xprofile-template..
1416 *
1417 */
1418
1419function get_showing_search_result($user_id)
1420{
1421 $user_references = bp_get_option("showing_references");
1422 $user_ref = $user_references[$user_id];
1423
1424 if ($user_ref["hide_street1"] === NULL)
1425 {
1426 $user_ref["hide_street1"] = 0;
1427 $user_ref["hide_street2"] = 0;
1428 $user_ref["hide_city"] = 0;
1429 $user_ref["hide_state"] = 0;
1430 $user_ref["hide_zip"] = 0;
1431 $user_ref["hide_country"] = 0;
1432 $user_ref["hide_email1"] = 0;
1433 $user_ref["hide_email2"] = 0;
1434 $user_ref["hide_phone1"] = 0;
1435 $user_ref["hide_phone2"] = 0;
1436 $user_ref["hide_profile"] = 0;
1437 $user_ref["hide_all"] = 0;
1438 }
1439 return $user_ref;
1440}
1441
1442function get_showing_search_result_current_user()
1443{
1444 global $bp;
1445 return get_showing_search_result($bp->displayed_user->id);
1446}
1447
1448function get_showing_search_result_current_user_from_tpl()
1449{
1450 global $members_template;
1451 return get_showing_search_result($members_template->member->id);
1452}
1453
1454
1455*************************************************************************************************************************************
1456*************************************************************************************************************************************
1457*************************************************************************************************************************************
1458*************************************************************************************************************************************
1459*************************************************************************************************************************************
1460
1461END OF CORE MODS
1462
1463*************************************************************************************************************************************
1464*************************************************************************************************************************************
1465*************************************************************************************************************************************
1466*************************************************************************************************************************************
1467*************************************************************************************************************************************
1468
1469/********************** COMMENTS ********************
1470 *
1471 * FunctionName: N/A
1472 * Description: Adds the filter to register the bp-dafault theme directory.
1473 * SourceFile: ../../wp-content/plugins/bp-custom.php
1474 * ChangeLog: Add the following filter to bp-custom.php.
1475 *
1476 */
1477
1478add_filter( 'bp_do_register_theme_directory', '__return_true' );