Changeset 5700
- Timestamp:
- 02/11/2012 02:29:55 AM (14 years ago)
- Location:
- trunk/bp-members
- Files:
-
- 1 deleted
- 9 edited
-
bp-members-actions.php (modified) (2 diffs)
-
bp-members-adminbar.php (modified) (2 diffs)
-
bp-members-buddybar.php (modified) (2 diffs)
-
bp-members-filters.php (modified) (2 diffs)
-
bp-members-functions.php (modified) (13 diffs)
-
bp-members-loader.php (modified) (4 diffs)
-
bp-members-notifications.php (modified) (2 diffs)
-
bp-members-screens.php (modified) (3 diffs)
-
bp-members-signup.php (deleted)
-
bp-members-template.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-members/bp-members-actions.php
r5410 r5700 1 1 <?php 2 /******************************************************************************* 3 * Action Functions 2 3 /** 4 * BuddyPress Members Actions 4 5 * 5 6 * Action functions are exactly the same as screen functions, however they do not 6 7 * have a template screen associated with them. Usually they will send the user 7 8 * back to the default screen after execution. 9 * 10 * @package BuddyPress 11 * @subpackage MembersActions 8 12 */ 9 13 … … 154 158 */ 155 159 function bp_core_get_random_member() { 156 global $bp; 160 if ( ! isset( $_GET['random-member'] ) ) 161 return; 157 162 158 if ( isset( $_GET['random-member'] ) ) { 159 $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) ); 160 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) ); 161 } 163 $user = bp_core_get_users( array( 'type' => 'random', 'per_page' => 1 ) ); 164 bp_core_redirect( bp_core_get_user_domain( $user['users'][0]->id ) ); 162 165 } 163 166 add_action( 'bp_actions', 'bp_core_get_random_member' ); 167 164 168 ?> -
trunk/bp-members/bp-members-adminbar.php
r5680 r5700 1 1 <?php 2 2 3 /** 3 4 * BuddyPress Members Admin Bar … … 6 7 * 7 8 * @package BuddyPress 8 * @subpackage Core9 * @subpackage MembersAdminBar 9 10 */ 10 11 -
trunk/bp-members/bp-members-buddybar.php
r5466 r5700 1 1 <?php 2 3 /** 4 * BuddyPress Members BuddyBar 5 * 6 * Handles the member functions related to the BuddyBar 7 * 8 * @package BuddyPress 9 * @subpackage MembersBuddyBar 10 */ 11 2 12 // Exit if accessed directly 3 13 if ( !defined( 'ABSPATH' ) ) exit; … … 42 52 add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 ); 43 53 44 // **** "Blog Authors" Menu (visible when not logged in) ******** 54 /** 55 * Blog Authors Menu (visible when not logged in) 56 */ 45 57 function bp_adminbar_authors_menu() { 46 global $ bp, $wpdb;58 global $wpdb; 47 59 48 60 // Only for multisite -
trunk/bp-members/bp-members-filters.php
r5289 r5700 1 1 <?php 2 2 3 /** 3 4 * BuddyPress Members Filters … … 6 7 * 7 8 * @package BuddyPress 8 * @subpackage Member Core9 * @subpackage MembersFilters 9 10 */ 10 11 -
trunk/bp-members/bp-members-functions.php
r5476 r5700 1 1 <?php 2 2 3 /** 3 4 * BuddyPress Member Functions … … 6 7 * 7 8 * @package BuddyPress 8 * @subpackage Members 9 * @subpackage MembersFunctions 9 10 */ 10 11 … … 74 75 */ 75 76 function bp_core_get_users( $args = '' ) { 76 global $bp;77 77 78 78 $defaults = array( … … 104 104 */ 105 105 function bp_core_get_user_domain( $user_id, $user_nicename = false, $user_login = false ) { 106 global $bp;107 106 108 107 if ( empty( $user_id ) ) … … 208 207 209 208 if ( !$username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' ) ) { 209 210 210 // Cache not found so prepare to update it 211 211 $update_cache = true; … … 333 333 */ 334 334 function bp_core_get_user_email( $uid ) { 335 335 336 if ( !$email = wp_cache_get( 'bp_user_email_' . $uid, 'bp' ) ) { 336 337 // User exists … … 477 478 */ 478 479 function bp_core_get_total_member_count() { 479 global $wpdb , $bp;480 global $wpdb; 480 481 481 482 if ( !$count = wp_cache_get( 'bp_total_member_count', 'bp' ) ) { … … 496 497 */ 497 498 function bp_is_user_spammer( $user_id = 0 ) { 498 global $wpdb;499 499 500 500 // No user to check … … 534 534 */ 535 535 function bp_is_user_deleted( $user_id = 0 ) { 536 global $wpdb;537 536 538 537 // No user to check … … 630 629 * 631 630 * @package BuddyPress Core 632 * @global object $bp Global BuddyPress settings object633 631 * @global $wpdb WordPress user data for the current logged in user. 634 632 * @return array of post ids. 635 633 */ 636 634 function bp_core_get_all_posts_for_user( $user_id = 0 ) { 637 global $ bp, $wpdb;635 global $wpdb; 638 636 639 637 if ( empty( $user_id ) ) … … 725 723 */ 726 724 function bp_core_boot_spammer( $auth_obj, $username ) { 727 global $bp;728 725 729 726 if ( !$user = get_user_by( 'login', $username ) ) … … 745 742 */ 746 743 function bp_core_remove_data( $user_id ) { 744 747 745 // Remove usermeta 748 746 bp_delete_user_meta( $user_id, 'last_activity' ); … … 765 763 } 766 764 765 /** Sign-up *******************************************************************/ 766 767 /** 768 * Flush illegal names by getting and setting 'illegal_names' site option 769 */ 770 function bp_core_flush_illegal_names() { 771 $illegal_names = get_site_option( 'illegal_names' ); 772 update_site_option( 'illegal_names', $illegal_names ); 773 } 774 775 /** 776 * Filter the illegal_names site option and make sure it includes a few 777 * specific BuddyPress and Multi-site slugs 778 * 779 * @param array|string $value Illegal names from field 780 * @param array|string $oldvalue The value as it is currently 781 * @return array Merged and unique array of illegal names 782 */ 783 function bp_core_get_illegal_names( $value = '', $oldvalue = '' ) { 784 785 // Make sure $value is array 786 if ( empty( $value ) ) 787 $db_illegal_names = array(); 788 if ( is_array( $value ) ) 789 $db_illegal_names = $value; 790 elseif ( is_string( $value ) ) 791 $db_illegal_names = explode( ' ', $value ); 792 793 // Add the core components' slugs to the banned list even if their components aren't active. 794 $bp_component_slugs = array( 795 'groups', 796 'members', 797 'forums', 798 'blogs', 799 'activity', 800 'profile', 801 'friends', 802 'search', 803 'settings', 804 'register', 805 'activate' 806 ); 807 808 // Core constants 809 $slug_constants = array( 810 'BP_GROUPS_SLUG', 811 'BP_MEMBERS_SLUG', 812 'BP_FORUMS_SLUG', 813 'BP_BLOGS_SLUG', 814 'BP_ACTIVITY_SLUG', 815 'BP_XPROFILE_SLUG', 816 'BP_FRIENDS_SLUG', 817 'BP_SEARCH_SLUG', 818 'BP_SETTINGS_SLUG', 819 'BP_REGISTER_SLUG', 820 'BP_ACTIVATION_SLUG', 821 ); 822 foreach( $slug_constants as $constant ) 823 if ( defined( $constant ) ) 824 $bp_component_slugs[] = constant( $constant ); 825 826 // Add our slugs to the array and allow them to be filtered 827 $filtered_illegal_names = apply_filters( 'bp_core_illegal_usernames', array_merge( array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ), $bp_component_slugs ) ); 828 829 // Merge the arrays together 830 $merged_names = array_merge( (array)$filtered_illegal_names, (array)$db_illegal_names ); 831 832 // Remove duplicates 833 $illegal_names = array_unique( (array)$merged_names ); 834 835 return apply_filters( 'bp_core_illegal_names', $illegal_names ); 836 } 837 add_filter( 'pre_update_site_option_illegal_names', 'bp_core_get_illegal_names', 10, 2 ); 838 839 /** 840 * Validate a user name and email address when creating a new user. 841 * 842 * @param string $user_name Username to validate 843 * @param string $user_email Email address to validate 844 * @return array Results of user validation including errors, if any 845 */ 846 function bp_core_validate_user_signup( $user_name, $user_email ) { 847 848 $errors = new WP_Error(); 849 $user_email = sanitize_email( $user_email ); 850 851 if ( empty( $user_name ) ) 852 $errors->add( 'user_name', __( 'Please enter a username', 'buddypress' ) ); 853 854 // Make sure illegal names include BuddyPress slugs and values 855 bp_core_flush_illegal_names(); 856 857 $illegal_names = get_site_option( 'illegal_names' ); 858 859 if ( !validate_username( $user_name ) || in_array( $user_name, (array)$illegal_names ) ) 860 $errors->add( 'user_name', __( 'Only lowercase letters and numbers allowed', 'buddypress' ) ); 861 862 if( strlen( $user_name ) < 4 ) 863 $errors->add( 'user_name', __( 'Username must be at least 4 characters', 'buddypress' ) ); 864 865 if ( strpos( ' ' . $user_name, '_' ) != false ) 866 $errors->add( 'user_name', __( 'Sorry, usernames may not contain the character "_"!', 'buddypress' ) ); 867 868 // Is the user_name all numeric? 869 $match = array(); 870 preg_match( '/[0-9]*/', $user_name, $match ); 871 872 if ( $match[0] == $user_name ) 873 $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!', 'buddypress' ) ); 874 875 if ( !is_email( $user_email ) ) 876 $errors->add( 'user_email', __( 'Please check your email address.', 'buddypress' ) ); 877 878 if ( function_exists( 'is_email_address_unsafe' ) && is_email_address_unsafe( $user_email ) ) 879 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) ); 880 881 $limited_email_domains = get_site_option( 'limited_email_domains', 'buddypress' ); 882 883 if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) { 884 $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) ); 885 886 if ( in_array( $emaildomain, (array)$limited_email_domains ) == false ) 887 $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!', 'buddypress' ) ); 888 } 889 890 // Check if the username has been used already. 891 if ( username_exists( $user_name ) ) 892 $errors->add( 'user_name', __( 'Sorry, that username already exists!', 'buddypress' ) ); 893 894 // Check if the email address has been used already. 895 if ( email_exists( $user_email ) ) 896 $errors->add( 'user_email', __( 'Sorry, that email address is already used!', 'buddypress' ) ); 897 898 $result = array( 'user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors ); 899 900 // Apply WPMU legacy filter 901 $result = apply_filters( 'wpmu_validate_user_signup', $result ); 902 903 return apply_filters( 'bp_core_validate_user_signup', $result ); 904 } 905 906 function bp_core_validate_blog_signup( $blog_url, $blog_title ) { 907 if ( !is_multisite() || !function_exists( 'wpmu_validate_blog_signup' ) ) 908 return false; 909 910 return apply_filters( 'bp_core_validate_blog_signup', wpmu_validate_blog_signup( $blog_url, $blog_title ) ); 911 } 912 913 function bp_core_signup_user( $user_login, $user_password, $user_email, $usermeta ) { 914 global $bp, $wpdb; 915 916 // Multisite installs have their own install procedure 917 if ( is_multisite() ) { 918 wpmu_signup_user( $user_login, $user_email, $usermeta ); 919 920 // On multisite, the user id is not created until the user activates the account 921 // but we need to cast $user_id to pass to the filters 922 $user_id = false; 923 924 } else { 925 $errors = new WP_Error(); 926 927 $user_id = wp_insert_user( array( 928 'user_login' => $user_login, 929 'user_pass' => $user_password, 930 'display_name' => sanitize_title( $user_login ), 931 'user_email' => $user_email 932 ) ); 933 934 if ( empty( $user_id ) ) { 935 $errors->add( 'registerfail', sprintf( __('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'buddypress' ), get_option( 'admin_email' ) ) ); 936 return $errors; 937 } 938 939 // Update the user status to '2' which we will use as 'not activated' (0 = active, 1 = spam, 2 = not active) 940 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 2 WHERE ID = %d", $user_id ) ); 941 942 // Set any profile data 943 if ( bp_is_active( 'xprofile' ) ) { 944 if ( !empty( $usermeta['profile_field_ids'] ) ) { 945 $profile_field_ids = explode( ',', $usermeta['profile_field_ids'] ); 946 947 foreach( (array)$profile_field_ids as $field_id ) { 948 if ( empty( $usermeta["field_{$field_id}"] ) ) 949 continue; 950 951 $current_field = $usermeta["field_{$field_id}"]; 952 xprofile_set_field_data( $field_id, $user_id, $current_field ); 953 } 954 } 955 } 956 } 957 $bp->signup->username = $user_login; 958 959 /*** 960 * Now generate an activation key and send an email to the user so they can activate their account 961 * and validate their email address. Multisite installs send their own email, so this is only for single blog installs. 962 * 963 * To disable sending activation emails you can user the filter 'bp_core_signup_send_activation_key' and return false. 964 */ 965 if ( apply_filters( 'bp_core_signup_send_activation_key', true ) ) { 966 if ( !is_multisite() ) { 967 $activation_key = wp_hash( $user_id ); 968 update_user_meta( $user_id, 'activation_key', $activation_key ); 969 bp_core_signup_send_validation_email( $user_id, $user_email, $activation_key ); 970 } 971 } 972 973 do_action( 'bp_core_signup_user', $user_id, $user_login, $user_password, $user_email, $usermeta ); 974 975 return $user_id; 976 } 977 978 function bp_core_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) { 979 if ( !is_multisite() || !function_exists( 'wpmu_signup_blog' ) ) 980 return false; 981 982 return apply_filters( 'bp_core_signup_blog', wpmu_signup_blog( $blog_domain, $blog_path, $blog_title, $user_name, $user_email, $usermeta ) ); 983 } 984 985 function bp_core_activate_signup( $key ) { 986 global $wpdb; 987 988 $user = false; 989 990 // Multisite installs have their own activation routine 991 if ( is_multisite() ) { 992 $user = wpmu_activate_signup( $key ); 993 994 // If there were errors, add a message and redirect 995 if ( !empty( $user->errors ) ) { 996 return $user; 997 } 998 999 $user_id = $user['user_id']; 1000 1001 // Set any profile data 1002 if ( bp_is_active( 'xprofile' ) ) { 1003 if ( !empty( $user['meta']['profile_field_ids'] ) ) { 1004 $profile_field_ids = explode( ',', $user['meta']['profile_field_ids'] ); 1005 1006 foreach( (array)$profile_field_ids as $field_id ) { 1007 $current_field = isset( $user['meta']["field_{$field_id}"] ) ? $user['meta']["field_{$field_id}"] : false; 1008 1009 if ( !empty( $current_field ) ) 1010 xprofile_set_field_data( $field_id, $user_id, $current_field ); 1011 } 1012 } 1013 } 1014 } else { 1015 1016 // Get the user_id based on the $key 1017 $user_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'activation_key' AND meta_value = %s", $key ) ); 1018 1019 if ( empty( $user_id ) ) 1020 return new WP_Error( 'invalid_key', __( 'Invalid activation key', 'buddypress' ) ); 1021 1022 // Change the user's status so they become active 1023 if ( !$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_status = 0 WHERE ID = %d", $user_id ) ) ) 1024 return new WP_Error( 'invalid_key', __( 'Invalid activation key', 'buddypress' ) ); 1025 1026 // Notify the site admin of a new user registration 1027 wp_new_user_notification( $user_id ); 1028 1029 // Remove the activation key meta 1030 delete_user_meta( $user_id, 'activation_key' ); 1031 } 1032 1033 // Update the display_name 1034 wp_update_user( array( 'ID' => $user_id, 'display_name' => bp_core_get_user_displayname( $user_id ) ) ); 1035 1036 // Set the password on multisite installs 1037 if ( is_multisite() && !empty( $user['meta']['password'] ) ) 1038 $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->users SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id ) ); 1039 1040 // Delete the total member cache 1041 wp_cache_delete( 'bp_total_member_count', 'bp' ); 1042 1043 do_action( 'bp_core_activated_user', $user_id, $key, $user ); 1044 1045 return $user_id; 1046 } 1047 1048 function bp_core_new_user_activity( $user ) { 1049 if ( empty( $user ) || !bp_is_active( 'activity' ) ) 1050 return false; 1051 1052 if ( is_array( $user ) ) 1053 $user_id = $user['user_id']; 1054 else 1055 $user_id = $user; 1056 1057 if ( empty( $user_id ) ) 1058 return false; 1059 1060 $userlink = bp_core_get_userlink( $user_id ); 1061 1062 bp_activity_add( array( 1063 'user_id' => $user_id, 1064 'action' => apply_filters( 'bp_core_activity_registered_member_action', sprintf( __( '%s became a registered member', 'buddypress' ), $userlink ), $user_id ), 1065 'component' => 'xprofile', 1066 'type' => 'new_member' 1067 ) ); 1068 } 1069 add_action( 'bp_core_activated_user', 'bp_core_new_user_activity' ); 1070 1071 function bp_core_map_user_registration( $user_id ) { 1072 1073 // Only map data when the site admin is adding users, not on registration. 1074 if ( !is_admin() ) 1075 return false; 1076 1077 // Add the user's fullname to Xprofile 1078 if ( bp_is_active( 'xprofile' ) ) { 1079 $firstname = get_user_meta( $user_id, 'first_name', true ); 1080 $lastname = ' ' . get_user_meta( $user_id, 'last_name', true ); 1081 $name = $firstname . $lastname; 1082 1083 if ( empty( $name ) || ' ' == $name ) 1084 $name = get_user_meta( $user_id, 'nickname', true ); 1085 1086 xprofile_set_field_data( 1, $user_id, $name ); 1087 } 1088 } 1089 add_action( 'user_register', 'bp_core_map_user_registration' ); 1090 1091 function bp_core_signup_avatar_upload_dir() { 1092 global $bp; 1093 1094 if ( !$bp->signup->avatar_dir ) 1095 return false; 1096 1097 $path = bp_core_avatar_upload_path() . '/avatars/signups/' . $bp->signup->avatar_dir; 1098 $newbdir = $path; 1099 1100 if ( !file_exists( $path ) ) 1101 @wp_mkdir_p( $path ); 1102 1103 $newurl = bp_core_avatar_url() . '/avatars/signups/' . $bp->signup->avatar_dir; 1104 $newburl = $newurl; 1105 $newsubdir = '/avatars/signups/' . $bp->signup->avatar_dir; 1106 1107 return apply_filters( 'bp_core_signup_avatar_upload_dir', array( 'path' => $path, 'url' => $newurl, 'subdir' => $newsubdir, 'basedir' => $newbdir, 'baseurl' => $newburl, 'error' => false ) ); 1108 } 1109 1110 function bp_core_signup_send_validation_email( $user_id, $user_email, $key ) { 1111 $activate_url = bp_get_activation_page() ."?key=$key"; 1112 $activate_url = esc_url( $activate_url ); 1113 1114 $from_name = ( '' == get_option( 'blogname' ) ) ? __( 'BuddyPress', 'buddypress' ) : esc_html( get_option( 'blogname' ) ); 1115 1116 $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%1\$s\n\n", 'buddypress' ), $activate_url ); 1117 $subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' ); 1118 1119 // Send the message 1120 $to = apply_filters( 'bp_core_signup_send_validation_email_to', $user_email, $user_id ); 1121 $subject = apply_filters( 'bp_core_signup_send_validation_email_subject', $subject, $user_id ); 1122 $message = apply_filters( 'bp_core_signup_send_validation_email_message', $message, $user_id, $activate_url ); 1123 1124 wp_mail( $to, $subject, $message ); 1125 1126 do_action( 'bp_core_sent_user_validation_email', $subject, $message, $user_id, $user_email, $key ); 1127 } 1128 1129 // Stop user accounts logging in that have not been activated (user_status = 2) 1130 function bp_core_signup_disable_inactive( $auth_obj, $username ) { 1131 global $wpdb; 1132 1133 if ( !$user_id = bp_core_get_userid( $username ) ) 1134 return $auth_obj; 1135 1136 $user_status = (int) $wpdb->get_var( $wpdb->prepare( "SELECT user_status FROM $wpdb->users WHERE ID = %d", $user_id ) ); 1137 1138 if ( 2 == $user_status ) 1139 return new WP_Error( 'bp_account_not_activated', __( '<strong>ERROR</strong>: Your account has not been activated. Check your email for the activation link.', 'buddypress' ) ); 1140 else 1141 return $auth_obj; 1142 } 1143 add_filter( 'authenticate', 'bp_core_signup_disable_inactive', 30, 2 ); 1144 1145 // Kill the wp-signup.php if custom registration signup templates are present 1146 function bp_core_wpsignup_redirect() { 1147 $action = !empty( $_GET['action'] ) ? $_GET['action'] : ''; 1148 1149 if ( is_admin() || is_network_admin() ) 1150 return; 1151 1152 // Not at the WP core signup page and action is not register 1153 if ( false === strpos( $_SERVER['SCRIPT_NAME'], 'wp-signup.php' ) && ( 'register' != $action ) ) 1154 return; 1155 1156 // Redirect to sign-up page 1157 if ( locate_template( array( 'registration/register.php' ), false ) || locate_template( array( 'register.php' ), false ) ) 1158 bp_core_redirect( bp_get_signup_page() ); 1159 } 1160 add_action( 'bp_init', 'bp_core_wpsignup_redirect' ); 1161 767 1162 ?> -
trunk/bp-members/bp-members-loader.php
r5474 r5700 34 34 function includes() { 35 35 $includes = array( 36 'signup',37 36 'actions', 38 37 'filters', … … 57 56 */ 58 57 function setup_globals() { 59 global $bp , $current_user, $displayed_user_id;58 global $bp; 60 59 61 60 // Define a slug, if necessary … … 133 132 // Add 'Profile' to the main navigation 134 133 if ( !bp_is_active( 'xprofile' ) ) { 134 135 135 // Don't set up navigation if there's no user 136 136 if ( !is_user_logged_in() && !bp_is_user() ) 137 137 return; 138 138 139 $sub_nav = array(); 139 140 $main_nav = array( 140 141 'name' => __( 'Profile', 'buddypress' ), … … 148 149 // User links 149 150 $user_domain = ( isset( $bp->displayed_user->domain ) ) ? $bp->displayed_user->domain : $bp->loggedin_user->domain; 150 $user_login = ( isset( $bp->displayed_user->userdata->user_login ) ) ? $bp->displayed_user->userdata->user_login : $bp->loggedin_user->userdata->user_login;151 151 $profile_link = trailingslashit( $user_domain . $bp->profile->slug ); 152 152 -
trunk/bp-members/bp-members-notifications.php
r5682 r5700 1 1 <?php 2 2 3 /** 3 4 * BuddyPress Member Notifications … … 6 7 * 7 8 * @package BuddyPress 8 * @subpackage Members 9 * @subpackage MembersNotifications 9 10 */ 10 11 -
trunk/bp-members/bp-members-screens.php
r5072 r5700 1 1 <?php 2 2 3 /** 3 4 * BuddyPress Member Screens … … 6 7 * 7 8 * @package BuddyPress 8 * @subpackage Members 9 * @subpackage MembersScreens 9 10 */ 10 11 … … 46 47 47 48 49 function bp_core_screen_signup() { 50 global $bp; 51 52 if ( !bp_is_current_component( 'register' ) ) 53 return; 54 55 // Not a directory 56 bp_update_is_directory( false, 'register' ); 57 58 // If the user is logged in, redirect away from here 59 if ( is_user_logged_in() ) { 60 if ( bp_is_component_front_page( 'register' ) ) 61 $redirect_to = trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ); 62 else 63 $redirect_to = bp_get_root_domain(); 64 65 bp_core_redirect( apply_filters( 'bp_loggedin_register_page_redirect_to', $redirect_to ) ); 66 67 return; 68 } 69 70 $bp->signup->step = 'request-details'; 71 72 if ( !bp_get_signup_allowed() ) { 73 $bp->signup->step = 'registration-disabled'; 74 } 75 76 // If the signup page is submitted, validate and save 77 elseif ( isset( $_POST['signup_submit'] ) ) { 78 79 // Check the nonce 80 check_admin_referer( 'bp_new_signup' ); 81 82 // Check the base account details for problems 83 $account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] ); 84 85 // If there are errors with account details, set them for display 86 if ( !empty( $account_details['errors']->errors['user_name'] ) ) 87 $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0]; 88 89 if ( !empty( $account_details['errors']->errors['user_email'] ) ) 90 $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0]; 91 92 // Check that both password fields are filled in 93 if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) ) 94 $bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' ); 95 96 // Check that the passwords match 97 if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] ) 98 $bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' ); 99 100 $bp->signup->username = $_POST['signup_username']; 101 $bp->signup->email = $_POST['signup_email']; 102 103 // Now we've checked account details, we can check profile information 104 if ( bp_is_active( 'xprofile' ) ) { 105 106 // Make sure hidden field is passed and populated 107 if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) { 108 109 // Let's compact any profile field info into an array 110 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 111 112 // Loop through the posted fields formatting any datebox values then validate the field 113 foreach ( (array) $profile_field_ids as $field_id ) { 114 if ( !isset( $_POST['field_' . $field_id] ) ) { 115 if ( !empty( $_POST['field_' . $field_id . '_day'] ) && !empty( $_POST['field_' . $field_id . '_month'] ) && !empty( $_POST['field_' . $field_id . '_year'] ) ) 116 $_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'] ) ); 117 } 118 119 // Create errors for required fields without values 120 if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) ) 121 $bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' ); 122 } 123 124 // This situation doesn't naturally occur so bounce to website root 125 } else { 126 bp_core_redirect( bp_get_root_domain() ); 127 } 128 } 129 130 // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled 131 if ( isset( $_POST['signup_with_blog'] ) ) { 132 $active_signup = $bp->site_options['registration']; 133 134 if ( 'blog' == $active_signup || 'all' == $active_signup ) { 135 $blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] ); 136 137 // If there are errors with blog details, set them for display 138 if ( !empty( $blog_details['errors']->errors['blogname'] ) ) 139 $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0]; 140 141 if ( !empty( $blog_details['errors']->errors['blog_title'] ) ) 142 $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0]; 143 } 144 } 145 146 do_action( 'bp_signup_validate' ); 147 148 // Add any errors to the action for the field in the template for display. 149 if ( !empty( $bp->signup->errors ) ) { 150 foreach ( (array)$bp->signup->errors as $fieldname => $error_message ) 151 add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\"error\">' . $error_message . '</div>" );' ) ); 152 } else { 153 $bp->signup->step = 'save-details'; 154 155 // No errors! Let's register those deets. 156 $active_signup = !empty( $bp->site_options['registration'] ) ? $bp->site_options['registration'] : ''; 157 158 if ( 'none' != $active_signup ) { 159 160 // Let's compact any profile field info into usermeta 161 $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] ); 162 163 // Loop through the posted fields formatting any datebox values then add to usermeta 164 foreach ( (array) $profile_field_ids as $field_id ) { 165 if ( !isset( $_POST['field_' . $field_id] ) ) { 166 if ( isset( $_POST['field_' . $field_id . '_day'] ) ) 167 $_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'] ) ); 168 } 169 170 if ( !empty( $_POST['field_' . $field_id] ) ) 171 $usermeta['field_' . $field_id] = $_POST['field_' . $field_id]; 172 } 173 174 // Store the profile field ID's in usermeta 175 $usermeta['profile_field_ids'] = $_POST['signup_profile_field_ids']; 176 177 // Hash and store the password 178 $usermeta['password'] = wp_hash_password( $_POST['signup_password'] ); 179 180 // If the user decided to create a blog, save those details to usermeta 181 if ( 'blog' == $active_signup || 'all' == $active_signup ) 182 $usermeta['public'] = ( isset( $_POST['signup_blog_privacy'] ) && 'public' == $_POST['signup_blog_privacy'] ) ? true : false; 183 184 $usermeta = apply_filters( 'bp_signup_usermeta', $usermeta ); 185 186 // Finally, sign up the user and/or blog 187 if ( isset( $_POST['signup_with_blog'] ) && is_multisite() ) 188 bp_core_signup_blog( $blog_details['domain'], $blog_details['path'], $blog_details['blog_title'], $_POST['signup_username'], $_POST['signup_email'], $usermeta ); 189 else 190 bp_core_signup_user( $_POST['signup_username'], $_POST['signup_password'], $_POST['signup_email'], $usermeta ); 191 192 $bp->signup->step = 'completed-confirmation'; 193 } 194 195 do_action( 'bp_complete_signup' ); 196 } 197 198 } 199 200 do_action( 'bp_core_screen_signup' ); 201 bp_core_load_template( apply_filters( 'bp_core_template_register', 'registration/register' ) ); 202 } 203 add_action( 'bp_screens', 'bp_core_screen_signup' ); 204 205 function bp_core_screen_activation() { 206 global $bp; 207 208 if ( !bp_is_current_component( 'activate' ) ) 209 return false; 210 211 // Check if an activation key has been passed 212 if ( isset( $_GET['key'] ) ) { 213 214 // Activate the signup 215 $user = apply_filters( 'bp_core_activate_account', bp_core_activate_signup( $_GET['key'] ) ); 216 217 // If there were errors, add a message and redirect 218 if ( !empty( $user->errors ) ) { 219 bp_core_add_message( $user->get_error_message(), 'error' ); 220 bp_core_redirect( trailingslashit( bp_get_root_domain() . '/' . $bp->pages->activate->slug ) ); 221 } 222 223 // Check for an uploaded avatar and move that to the correct user folder 224 if ( is_multisite() ) 225 $hashed_key = wp_hash( $_GET['key'] ); 226 else 227 $hashed_key = wp_hash( $user ); 228 229 // Check if the avatar folder exists. If it does, move rename it, move 230 // it and delete the signup avatar dir 231 if ( file_exists( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key ) ) 232 @rename( bp_core_avatar_upload_path() . '/avatars/signups/' . $hashed_key, bp_core_avatar_upload_path() . '/avatars/' . $user ); 233 234 bp_core_add_message( __( 'Your account is now active!', 'buddypress' ) ); 235 236 $bp->activation_complete = true; 237 } 238 239 if ( '' != locate_template( array( 'registration/activate' ), false ) ) 240 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'activate' ) ); 241 else 242 bp_core_load_template( apply_filters( 'bp_core_template_activate', 'registration/activate' ) ); 243 } 244 add_action( 'bp_screens', 'bp_core_screen_activation' ); 245 48 246 ?> -
trunk/bp-members/bp-members-template.php
r5646 r5700 1 1 <?php 2 2 3 /** 3 4 * BuddyPress Member Template Tags … … 169 170 var $total_member_count; 170 171 171 function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value ) {172 $this->__construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value );173 }174 175 172 function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value ) { 176 global $bp; 177 178 $this->pag_page = !empty( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : (int)$page_number; 179 $this->pag_num = !empty( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : (int)$per_page; 180 $this->type = $type; 173 174 $this->pag_page = !empty( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : (int)$page_number; 175 $this->pag_num = !empty( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : (int)$per_page; 176 $this->type = $type; 181 177 182 178 if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] ) … … 250 246 251 247 function the_member() { 252 global $member, $bp;253 248 254 249 $this->in_the_loop = true; 255 $this->member = $this->next_member(); 256 257 if ( 0 == $this->current_member ) // loop has just started 258 do_action('member_loop_start'); 250 $this->member = $this->next_member(); 251 252 // loop has just started 253 if ( 0 == $this->current_member ) 254 do_action( 'member_loop_start' ); 259 255 } 260 256 } … … 267 263 268 264 function bp_has_members( $args = '' ) { 269 global $ bp, $members_template;265 global $members_template; 270 266 271 267 /*** … … 339 335 } 340 336 function bp_get_members_pagination_count() { 341 global $ bp, $members_template;337 global $members_template; 342 338 343 339 if ( empty( $members_template->type ) ) … … 464 460 465 461 function bp_member_is_loggedin_user() { 466 global $ bp, $members_template;462 global $members_template; 467 463 return apply_filters( 'bp_member_is_loggedin_user', bp_loggedin_user_id() == $members_template->member->id ? true : false ); 468 464 } … … 472 468 } 473 469 function bp_get_member_avatar( $args = '' ) { 474 global $ bp, $members_template;470 global $members_template; 475 471 476 472 $fullname = !empty( $members_template->member->fullname ) ? $members_template->member->fullname : $members_template->member->display_name; 477 473 478 474 $defaults = array( 479 'type' => 'thumb',480 'width' => false,475 'type' => 'thumb', 476 'width' => false, 481 477 'height' => false, 482 'class' => 'avatar',483 'id' => false,484 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $fullname )478 'class' => 'avatar', 479 'id' => false, 480 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $fullname ) 485 481 ); 486 482 … … 568 564 } 569 565 function bp_get_member_latest_update( $args = '' ) { 570 global $ bp, $members_template;566 global $members_template; 571 567 572 568 $defaults = array( … … 598 594 } 599 595 function bp_get_member_profile_data( $args = '' ) { 600 global $ bp, $members_template;596 global $members_template; 601 597 602 598 if ( !bp_is_active( 'xprofile' ) ) … … 665 661 666 662 function bp_directory_members_search_form() { 667 global $bp;668 663 669 664 $default_search_value = bp_get_search_default_text( 'members' ); … … 707 702 // Loop through each navigation item 708 703 foreach( (array) $bp->bp_nav as $nav_item ) { 704 705 $selected = ''; 706 709 707 // If the current component matches the nav item id, then add a highlight CSS class. 710 if ( !bp_is_directory() && $bp->active_components[$bp->current_component] == $nav_item['css_id'] ) 708 if ( !bp_is_directory() && $bp->active_components[$bp->current_component] == $nav_item['css_id'] ) { 711 709 $selected = ' class="current selected"'; 712 else713 $selected = ''; 714 715 / * If we are viewing another person (current_userid does not equal loggedin_user->id)716 then check to see if the two users are friends. if they are, add a highlight CSS class717 to the friends nav item if it exists. */710 } 711 712 // If we are viewing another person (current_userid does not equal 713 // loggedin_user->id then check to see if the two users are friends. 714 // if they are, add a highlight CSS class to the friends nav item 715 // if it exists. 718 716 if ( !bp_is_my_profile() && bp_displayed_user_id() ) { 719 717 $selected = ''; … … 721 719 if ( bp_is_active( 'friends' ) ) { 722 720 if ( $nav_item['css_id'] == $bp->friends->id ) { 723 if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) 721 if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) { 724 722 $selected = ' class="current selected"'; 723 } 725 724 } 726 725 } … … 751 750 continue; 752 751 753 if ( $bp->current_component == $user_nav_item['slug'] ) 752 $selected = ''; 753 if ( $bp->current_component == $user_nav_item['slug'] ) { 754 754 $selected = ' class="current selected"'; 755 else 756 $selected = ''; 757 758 if ( $bp->loggedin_user->domain ) 755 } 756 757 if ( $bp->loggedin_user->domain ) { 759 758 $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] ); 760 else759 } else { 761 760 $link = trailingslashit( $bp->displayed_user->domain . $user_nav_item['link'] ); 761 } 762 762 763 763 echo apply_filters_ref_array( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], array( '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ) ); … … 771 771 } 772 772 function bp_get_loggedin_user_avatar( $args = '' ) { 773 global $bp;774 773 775 774 $defaults = array( … … 791 790 } 792 791 function bp_get_displayed_user_avatar( $args = '' ) { 793 global $bp;794 792 795 793 $defaults = array( … … 826 824 } 827 825 function bp_get_last_activity( $user_id = 0 ) { 828 global $bp;829 826 830 827 if ( empty( $user_id ) ) … … 967 964 } 968 965 function bp_get_signup_page() { 969 global $bp;970 966 971 967 if ( bp_has_custom_signup_page() ) {
Note: See TracChangeset
for help on using the changeset viewer.