Advertisement
mnctigah

members-loop/changelog

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