• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP xprofile_check_is_required_field函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中xprofile_check_is_required_field函数的典型用法代码示例。如果您正苦于以下问题:PHP xprofile_check_is_required_field函数的具体用法?PHP xprofile_check_is_required_field怎么用?PHP xprofile_check_is_required_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了xprofile_check_is_required_field函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: bp_core_screen_signup

/**
 * Handle the loading of the signup screen.
 */
function bp_core_screen_signup()
{
    global $bp;
    if (!bp_is_current_component('register') || bp_current_action()) {
        return;
    }
    // Not a directory
    bp_update_is_directory(false, 'register');
    // If the user is logged in, redirect away from here
    if (is_user_logged_in()) {
        if (bp_is_component_front_page('register')) {
            $redirect_to = trailingslashit(bp_get_root_domain() . '/' . bp_get_members_root_slug());
        } else {
            $redirect_to = bp_get_root_domain();
        }
        /**
         * Filters the URL to redirect logged in users to when visiting registration page.
         *
         * @since BuddyPress (1.5.1)
         *
         * @param string $redirect_to URL to redirect user to.
         */
        bp_core_redirect(apply_filters('bp_loggedin_register_page_redirect_to', $redirect_to));
        return;
    }
    $bp->signup->step = 'request-details';
    if (!bp_get_signup_allowed()) {
        $bp->signup->step = 'registration-disabled';
        // If the signup page is submitted, validate and save
    } elseif (isset($_POST['signup_submit']) && bp_verify_nonce_request('bp_new_signup')) {
        /**
         * Fires before the validation of a new signup.
         *
         * @since BuddyPress (2.0.0)
         */
        do_action('bp_signup_pre_validate');
        // Check the base account details for problems
        $account_details = bp_core_validate_user_signup($_POST['signup_username'], $_POST['signup_email']);
        // If there are errors with account details, set them for display
        if (!empty($account_details['errors']->errors['user_name'])) {
            $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
        }
        if (!empty($account_details['errors']->errors['user_email'])) {
            $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
        }
        // Check that both password fields are filled in
        if (empty($_POST['signup_password']) || empty($_POST['signup_password_confirm'])) {
            $bp->signup->errors['signup_password'] = __('Please make sure you enter your password twice', 'buddypress');
        }
        // Check that the passwords match
        if (!empty($_POST['signup_password']) && !empty($_POST['signup_password_confirm']) && $_POST['signup_password'] != $_POST['signup_password_confirm']) {
            $bp->signup->errors['signup_password'] = __('The passwords you entered do not match.', 'buddypress');
        }
        $bp->signup->username = $_POST['signup_username'];
        $bp->signup->email = $_POST['signup_email'];
        // Now we've checked account details, we can check profile information
        if (bp_is_active('xprofile')) {
            // Make sure hidden field is passed and populated
            if (isset($_POST['signup_profile_field_ids']) && !empty($_POST['signup_profile_field_ids'])) {
                // Let's compact any profile field info into an array
                $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
                // Loop through the posted fields formatting any datebox values then validate the field
                foreach ((array) $profile_field_ids as $field_id) {
                    if (!isset($_POST['field_' . $field_id])) {
                        if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                            $_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']));
                        }
                    }
                    // Create errors for required fields without values
                    if (xprofile_check_is_required_field($field_id) && empty($_POST['field_' . $field_id])) {
                        $bp->signup->errors['field_' . $field_id] = __('This is a required field', 'buddypress');
                    }
                }
                // This situation doesn't naturally occur so bounce to website root
            } else {
                bp_core_redirect(bp_get_root_domain());
            }
        }
        // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled
        if (isset($_POST['signup_with_blog'])) {
            $active_signup = $bp->site_options['registration'];
            if ('blog' == $active_signup || 'all' == $active_signup) {
                $blog_details = bp_core_validate_blog_signup($_POST['signup_blog_url'], $_POST['signup_blog_title']);
                // If there are errors with blog details, set them for display
                if (!empty($blog_details['errors']->errors['blogname'])) {
                    $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
                }
                if (!empty($blog_details['errors']->errors['blog_title'])) {
                    $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0];
                }
            }
        }
        /**
         * Fires after the validation of a new signup.
         *
         * @since BuddyPress (1.1.0)
         */
//.........这里部分代码省略.........
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:101,代码来源:bp-members-screens.php


示例2: do_subscription_form


//.........这里部分代码省略.........
             }
             if (!is_email($_POST['signup_email'])) {
                 $error->add('emailnotvalid', __('The email address is not valid, sorry.', 'membership'));
             }
             if (email_exists($_POST['signup_email'])) {
                 $error->add('emailexists', __('That email address is already taken, sorry.', 'membership'));
             }
             // Initial fix provided by user: cmurtagh - modified to add extra checks and rejigged a bit
             // Run the buddypress validation
             do_action('bp_signup_validate');
             // Add any errors to the action for the field in the template for display.
             if (!empty($bp->signup->errors)) {
                 foreach ((array) $bp->signup->errors as $fieldname => $error_message) {
                     $error->add($fieldname, $error_message);
                 }
             }
             $meta_array = array();
             // xprofile required fields
             /* Now we've checked account details, we can check profile information */
             //if ( function_exists( 'xprofile_check_is_required_field' ) ) {
             if (function_exists('bp_is_active') && bp_is_active('xprofile')) {
                 /* Make sure hidden field is passed and populated */
                 if (isset($_POST['signup_profile_field_ids']) && !empty($_POST['signup_profile_field_ids'])) {
                     /* Let's compact any profile field info into an array */
                     $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
                     /* Loop through the posted fields formatting any datebox values then validate the field */
                     foreach ((array) $profile_field_ids as $field_id) {
                         if (!isset($_POST['field_' . $field_id])) {
                             if (isset($_POST['field_' . $field_id . '_day'])) {
                                 $_POST['field_' . $field_id] = strtotime($_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year']);
                             }
                         }
                         /* Create errors for required fields without values */
                         if (xprofile_check_is_required_field($field_id) && empty($_POST['field_' . $field_id])) {
                             $field = new BP_Xprofile_Field($field_id);
                             $error->add($field->name, __('Please ensure that the ', 'membership') . "<strong>" . $field->name . "</strong>" . __(' information is completed.', 'membership'));
                         }
                         $meta_array[$field_id] = $_POST['field_' . $field_id];
                     }
                 }
             }
             $error = apply_filters('membership_subscription_form_before_registration_process', $error);
             // Hack for now - eeek
             $anyerrors = $error->get_error_code();
             if (empty($anyerrors)) {
                 // No errors so far - error reporting check for final add user *note $error should always be an error object becuase we created it as such.
                 $user_id = wp_create_user(sanitize_user($_POST['signup_username']), $_POST['signup_password'], $_POST['signup_email']);
                 if (is_wp_error($user_id) && method_exists($userid, 'get_error_message')) {
                     $error->add('userid', $user_id->get_error_message());
                 } else {
                     $member = new M_Membership($user_id);
                     if (defined('MEMBERSHIP_DEACTIVATE_USER_ON_REGISTRATION') && MEMBERSHIP_DEACTIVATE_USER_ON_REGISTRATION == true) {
                         $member->deactivate();
                     } else {
                         $creds = array('user_login' => $_POST['signup_username'], 'user_password' => $_POST['signup_password'], 'remember' => true);
                         if (!headers_sent()) {
                             $is_ssl = isset($_SERVER['https']) && strtolower($_SERVER['https']) == 'on' ? true : false;
                             $user = @wp_signon($creds, $is_ssl);
                             if (is_wp_error($user) && method_exists($user, 'get_error_message')) {
                                 $error->add('userlogin', $user->get_error_message());
                             } else {
                                 // Set the current user up
                                 wp_set_current_user($user_id);
                             }
                         } else {
                             // Set the current user up
开发者ID:EdoMagen,项目名称:project-s-v2,代码行数:67,代码来源:membershippublic.php


示例3: xprofile_screen_edit_profile

/**
 * Handles the display of the profile edit page by loading the correct template file.
 * Also checks to make sure this can only be accessed for the logged in users profile.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_edit_profile()
{
    global $bp;
    if (!bp_is_my_profile() && !is_super_admin()) {
        return false;
    }
    // Make sure a group is set.
    if (!bp_action_variable(1)) {
        bp_core_redirect(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1');
    }
    // Check the field group exists
    if (!bp_is_action_variable('group') || !xprofile_get_field_group(bp_action_variable(1))) {
        bp_do_404();
        return;
    }
    // Check to see if any new information has been submitted
    if (isset($_POST['field_ids'])) {
        // Check the nonce
        check_admin_referer('bp_xprofile_edit');
        // Check we have field ID's
        if (empty($_POST['field_ids'])) {
            bp_core_redirect(trailingslashit($bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
        // Explode the posted field IDs into an array so we know which
        // fields have been submitted
        $posted_field_ids = explode(',', $_POST['field_ids']);
        $is_required = array();
        // Loop through the posted fields formatting any datebox values
        // then validate the field
        foreach ((array) $posted_field_ids as $field_id) {
            if (!isset($_POST['field_' . $field_id])) {
                if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                    // Concatenate the values
                    $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
                    // Turn the concatenated value into a timestamp
                    $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
                }
            }
            $is_required[$field_id] = xprofile_check_is_required_field($field_id);
            if ($is_required[$field_id] && empty($_POST['field_' . $field_id])) {
                $errors = true;
            }
        }
        // There are errors
        if (!empty($errors)) {
            bp_core_add_message(__('Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress'), 'error');
            // No errors
        } else {
            // Reset the errors var
            $errors = false;
            // Now we've checked for required fields, lets save the values.
            foreach ((array) $posted_field_ids as $field_id) {
                // 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.
                if (empty($_POST['field_' . $field_id])) {
                    $value = array();
                } else {
                    $value = $_POST['field_' . $field_id];
                }
                if (!xprofile_set_field_data($field_id, $bp->displayed_user->id, $value, $is_required[$field_id])) {
                    $errors = true;
                } else {
                    do_action('xprofile_profile_field_data_updated', $field_id, $value);
                }
            }
            do_action('xprofile_updated_profile', $bp->displayed_user->id, $posted_field_ids, $errors);
            // Set the feedback messages
            if ($errors) {
                bp_core_add_message(__('There was a problem updating some of your profile information, please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Changes saved.', 'buddypress'));
            }
            // Redirect back to the edit screen to display the updates and message
            bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
    }
    do_action('xprofile_screen_edit_profile');
    bp_core_load_template(apply_filters('xprofile_template_edit_profile', 'members/single/home'));
}
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:86,代码来源:bp-xprofile-screens.php


示例4: xprofile_screen_edit_profile

/**
 * Handles the display of the profile edit page by loading the correct template file.
 * Also checks to make sure this can only be accessed for the logged in users profile.
 *
 * @package BuddyPress XProfile
 * @uses bp_is_my_profile() Checks to make sure the current user being viewed equals the logged in user
 * @uses bp_core_load_template() Looks for and loads a template file within the current member theme (folder/filename)
 */
function xprofile_screen_edit_profile()
{
    if (!bp_is_my_profile() && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    $bp = buddypress();
    // Make sure a group is set.
    if (!bp_action_variable(1)) {
        bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/1'));
    }
    // Check the field group exists
    if (!bp_is_action_variable('group') || !xprofile_get_field_group(bp_action_variable(1))) {
        bp_do_404();
        return;
    }
    // No errors
    $errors = false;
    // Check to see if any new information has been submitted
    if (isset($_POST['field_ids'])) {
        // Check the nonce
        check_admin_referer('bp_xprofile_edit');
        // Check we have field ID's
        if (empty($_POST['field_ids'])) {
            bp_core_redirect(trailingslashit(bp_displayed_user_domain() . $bp->profile->slug . '/edit/group/' . bp_action_variable(1)));
        }
        // Explode the posted field IDs into an array so we know which
        // fields have been submitted
        $posted_field_ids = wp_parse_id_list($_POST['field_ids']);
        $is_required = array();
        // Loop through the posted fields formatting any datebox values
        // then validate the field
        foreach ((array) $posted_field_ids as $field_id) {
            if (!isset($_POST['field_' . $field_id])) {
                if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                    // Concatenate the values
                    $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
                    // Turn the concatenated value into a timestamp
                    $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
                }
            }
            $is_required[$field_id] = xprofile_check_is_required_field($field_id);
            if ($is_required[$field_id] && empty($_POST['field_' . $field_id])) {
                $errors = true;
            }
        }
        // There are errors
        if (!empty($errors)) {
            bp_core_add_message(__('Please make sure you fill in all required fields in this profile field group before saving.', 'buddypress'), 'error');
            // No errors
        } else {
            // Reset the errors var
            $errors = false;
            // Now we've checked for required fields, lets save the values.
            $old_values = $new_values = array();
            foreach ((array) $posted_field_ids as $field_id) {
                // 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.
                $value = isset($_POST['field_' . $field_id]) ? $_POST['field_' . $field_id] : '';
                $visibility_level = !empty($_POST['field_' . $field_id . '_visibility']) ? $_POST['field_' . $field_id . '_visibility'] : 'public';
                // Save the old and new values. They will be
                // passed to the filter and used to determine
                // whether an activity item should be posted
                $old_values[$field_id] = array('value' => xprofile_get_field_data($field_id, bp_displayed_user_id()), 'visibility' => xprofile_get_field_visibility_level($field_id, bp_displayed_user_id()));
                // Update the field data and visibility level
                xprofile_set_field_visibility_level($field_id, bp_displayed_user_id(), $visibility_level);
                $field_updated = xprofile_set_field_data($field_id, bp_displayed_user_id(), $value, $is_required[$field_id]);
                $value = xprofile_get_field_data($field_id, bp_displayed_user_id());
                $new_values[$field_id] = array('value' => $value, 'visibility' => xprofile_get_field_visibility_level($field_id, bp_displayed_user_id()));
                if (!$field_updated) {
                    $errors = true;
                } else {
                    /**
                     * Fires on each iteration of an XProfile field being saved with no error.
                     *
                     * @since BuddyPress (1.1.0)
                     *
                     * @param int    $field_id ID of the field that was saved.
                     * @param string $value    Value that was saved to the field.
                     */
                    do_action('xprofile_profile_field_data_updated', $field_id, $value);
                }
            }
            /**
             * Fires after all XProfile fields have been saved for the current profile.
             *
             * @since BuddyPress (1.0.0)
             *
             * @param int   $value            Displayed user ID.
             * @param array $posted_field_ids Array of field IDs that were edited.
             * @param bool  $errors           Whether or not any errors occurred.
             * @param array $old_values       Array of original values before updated.
             * @param array $new_values       Array of newly saved values after update.
             */
//.........这里部分代码省略.........
开发者ID:kosir,项目名称:thatcamp-org,代码行数:101,代码来源:bp-xprofile-screens.php


示例5: user_admin_load

 /**
  * Save the profile fields in Members community profile page.
  *
  * Loaded before the page is rendered, this function is processing form
  * requests.
  *
  * @since 2.0.0
  *
  * @param string $doaction    Action being run.
  * @param int    $user_id     ID for the user whose profile is being saved.
  * @param array  $request     Request being made.
  * @param string $redirect_to Where to redirect user to.
  */
 public function user_admin_load($doaction = '', $user_id = 0, $request = array(), $redirect_to = '')
 {
     // Eventually delete avatar.
     if ('delete_avatar' === $doaction) {
         check_admin_referer('delete_avatar');
         $redirect_to = remove_query_arg('_wpnonce', $redirect_to);
         if (bp_core_delete_existing_avatar(array('item_id' => $user_id))) {
             $redirect_to = add_query_arg('updated', 'avatar', $redirect_to);
         } else {
             $redirect_to = add_query_arg('error', 'avatar', $redirect_to);
         }
         bp_core_redirect($redirect_to);
         // Update profile fields.
     } elseif (isset($_POST['field_ids'])) {
         // Check the nonce.
         check_admin_referer('edit-bp-profile_' . $user_id);
         // Check we have field ID's.
         if (empty($_POST['field_ids'])) {
             $redirect_to = add_query_arg('error', '1', $redirect_to);
             bp_core_redirect($redirect_to);
         }
         /**
          * Unlike front-end edit-fields screens, the wp-admin/profile
          * displays all groups of fields on a single page, so the list of
          * field ids is an array gathering for each group of fields a
          * distinct comma separated list of ids.
          *
          * As a result, before using the wp_parse_id_list() function, we
          * must ensure that these ids are "merged" into a single comma
          * separated list.
          */
         $merge_ids = join(',', $_POST['field_ids']);
         // Explode the posted field IDs into an array so we know which fields have been submitted.
         $posted_field_ids = wp_parse_id_list($merge_ids);
         $is_required = array();
         // Loop through the posted fields formatting any datebox values then validate the field.
         foreach ((array) $posted_field_ids as $field_id) {
             if (!isset($_POST['field_' . $field_id])) {
                 if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                     // Concatenate the values.
                     $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
                     // Turn the concatenated value into a timestamp.
                     $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
                 }
             }
             $is_required[$field_id] = xprofile_check_is_required_field($field_id) && !bp_current_user_can('bp_moderate');
             if ($is_required[$field_id] && empty($_POST['field_' . $field_id])) {
                 $redirect_to = add_query_arg('error', '2', $redirect_to);
                 bp_core_redirect($redirect_to);
             }
         }
         // Set the errors var.
         $errors = false;
         // Now we've checked for required fields, let's save the values.
         foreach ((array) $posted_field_ids as $field_id) {
             // 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.
             $value = isset($_POST['field_' . $field_id]) ? $_POST['field_' . $field_id] : '';
             if (!xprofile_set_field_data($field_id, $user_id, $value, $is_required[$field_id])) {
                 $errors = true;
             } else {
                 /**
                  * Fires after the saving of each profile field, if successful.
                  *
                  * @since 1.1.0
                  *
                  * @param int    $field_id ID of the field being updated.
                  * @param string $value    Value that was saved to the field.
                  */
                 do_action('xprofile_profile_field_data_updated', $field_id, $value);
             }
             // Save the visibility level.
             $visibility_level = !empty($_POST['field_' . $field_id . '_visibility']) ? $_POST['field_' . $field_id . '_visibility'] : 'public';
             xprofile_set_field_visibility_level($field_id, $user_id, $visibility_level);
         }
         /**
          * Fires after all of the profile fields have been saved.
          *
          * @since 1.0.0
          *
          * @param int   $user_id          ID of the user whose data is being saved.
          * @param array $posted_field_ids IDs of the fields that were submitted.
          * @param bool  $errors           Whether or not errors occurred during saving.
          */
         do_action('xprofile_updated_profile', $user_id, $posted_field_ids, $errors);
         // Set the feedback messages.
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:class-bp-xprofile-user-admin.php


示例6: array

 /* Check for required BuddyPress fields. */
 if ($bp_field_ids && $xprofile_active) {
     /* Index required fields */
     $is_required = array();
     /* Check for required fields */
     foreach ((array) $bp_field_ids as $field_id) {
         /* Special case for date fields. */
         if (!isset($_POST['field_' . $field_id])) {
             if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                 $date_value = $_POST['field_' . $field_id . '_day'] . ' ' . $_POST['field_' . $field_id . '_month'] . ' ' . $_POST['field_' . $field_id . '_year'];
                 /* Merge date fields */
                 $_POST['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
             }
         }
         /* Mark field as required */
         $is_required[$field_id] = xprofile_check_is_required_field($field_id);
         if ($is_required[$field_id] && empty($_POST['field_' . $field_id])) {
             $field = xprofile_get_field($field_id);
             $errors->add('field_' . $field_id, sprintf(__('%s is required.', 'membership'), $field->name));
             unset($field);
         }
     }
 }
 if (!empty($_POST['pass1']) && $_POST['pass1'] != $_POST['pass2']) {
     $errors->add('pass1', __('Your password settings do not match', 'membership'));
 }
 /* Update the user. */
 if (!$errors->get_error_code()) {
     /* Update user with fields from $_POST and get response. */
     $response = edit_user($user_id);
     /* If there are no errors and Extended Profiles are active... */
开发者ID:vilmark,项目名称:vilmark_main,代码行数:31,代码来源:bp.account.form.php


示例7: bp_core_screen_signup

function bp_core_screen_signup()
{
    global $bp, $wpdb;
    if (!bp_is_current_component('register')) {
        return;
    }
    // Not a directory
    bp_update_is_directory(false, 'register');
    // If the user is logged in, redirect away from here
    if (is_user_logged_in()) {
        if (bp_is_component_front_page('register')) {
            $redirect_to = bp_get_root_domain() . '/' . bp_get_members_root_slug();
        } else {
            $redirect_to = bp_get_root_domain();
        }
        bp_core_redirect(apply_filters('bp_loggedin_register_page_redirect_to', $redirect_to));
        return;
    }
    $bp->signup->step = 'request-details';
    if (!bp_get_signup_allowed()) {
        $bp->signup->step = 'registration-disabled';
    } elseif (isset($_POST['signup_submit'])) {
        // Check the nonce
        check_admin_referer('bp_new_signup');
        // Check the base account details for problems
        $account_details = bp_core_validate_user_signup($_POST['signup_username'], $_POST['signup_email']);
        // If there are errors with account details, set them for display
        if (!empty($account_details['errors']->errors['user_name'])) {
            $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
        }
        if (!empty($account_details['errors']->errors['user_email'])) {
            $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
        }
        // Check that both password fields are filled in
        if (empty($_POST['signup_password']) || empty($_POST['signup_password_confirm'])) {
            $bp->signup->errors['signup_password'] = __('Please make sure you enter your password twice', 'buddypress');
        }
        // Check that the passwords match
        if (!empty($_POST['signup_password']) && !empty($_POST['signup_password_confirm']) && $_POST['signup_password'] != $_POST['signup_password_confirm']) {
            $bp->signup->errors['signup_password'] = __('The passwords you entered do not match.', 'buddypress');
        }
        $bp->signup->username = $_POST['signup_username'];
        $bp->signup->email = $_POST['signup_email'];
        // Now we've checked account details, we can check profile information
        if (bp_is_active('xprofile')) {
            // Make sure hidden field is passed and populated
            if (isset($_POST['signup_profile_field_ids']) && !empty($_POST['signup_profile_field_ids'])) {
                // Let's compact any profile field info into an array
                $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
                // Loop through the posted fields formatting any datebox values then validate the field
                foreach ((array) $profile_field_ids as $field_id) {
                    if (!isset($_POST['field_' . $field_id])) {
                        if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                            $_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']));
                        }
                    }
                    // Create errors for required fields without values
                    if (xprofile_check_is_required_field($field_id) && empty($_POST['field_' . $field_id])) {
                        $bp->signup->errors['field_' . $field_id] = __('This is a required field', 'buddypress');
                    }
                }
                // This situation doesn't naturally occur so bounce to website root
            } else {
                bp_core_redirect(bp_get_root_domain());
            }
        }
        // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled
        if (isset($_POST['signup_with_blog'])) {
            $active_signup = $bp->site_options['registration'];
            if ('blog' == $active_signup || 'all' == $active_signup) {
                $blog_details = bp_core_validate_blog_signup($_POST['signup_blog_url'], $_POST['signup_blog_title']);
                // If there are errors with blog details, set them for display
                if (!empty($blog_details['errors']->errors['blogname'])) {
                    $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
                }
                if (!empty($blog_details['errors']->errors['blog_title'])) {
                    $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0];
                }
            }
        }
        do_action('bp_signup_validate');
        // Add any errors to the action for the field in the template for display.
        if (!empty($bp->signup->errors)) {
            foreach ((array) $bp->signup->errors as $fieldname => $error_message) {
                add_action('bp_' . $fieldname . '_errors', create_function('', 'echo apply_filters(\'bp_members_signup_error_message\', "<div class=\\"error\\">' . $error_message . '</div>" );'));
            }
        } else {
            $bp->signup->step = 'save-details';
            // No errors! Let's register those deets.
            $active_signup = !empty($bp->site_options['registration']) ? $bp->site_options['registration'] : '';
            if ('none' != $active_signup) {
                // Let's compact any profile field info into usermeta
                $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
                // Loop through the posted fields formatting any datebox values then add to usermeta
                foreach ((array) $profile_field_ids as $field_id) {
                    if (!isset($_POST['field_' . $field_id])) {
                        if (isset($_POST['field_' . $field_id . '_day'])) {
                            $_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']));
                        }
                    }
//.........这里部分代码省略.........
开发者ID:newington,项目名称:buddypress,代码行数:101,代码来源:bp-members-signup.php


示例8: _check_xprofile_fields

 /**
  * Check the xprofile fields validation
  * when using buddypress registration form on signup
  *
  * @since  1.0.2.5
  * @return void
  */
 private function _check_xprofile_fields()
 {
     $bp = buddypress();
     // Make sure hidden field is passed and populated.
     if (isset($_POST['signup_profile_field_ids']) && !empty($_POST['signup_profile_field_ids'])) {
         // Let's compact any profile field info into an array.
         $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
         // Loop through the posted fields formatting any datebox values then validate the field.
         foreach ((array) $profile_field_ids as $field_id) {
             if (!isset($_POST['field_' . $field_id])) {
                 if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                     $_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']));
                 }
             }
             // Create errors for required fields without values.
             if (xprofile_check_is_required_field($field_id) && empty($_POST['field_' . $field_id]) && !bp_current_user_can('bp_moderate')) {
                 $bp->signup->errors['field_' . $field_id] = __('This is a required field', 'membership2');
             }
         }
         // This situation doesn't naturally occur so bounce to website root.
     } else {
         bp_core_redirect(bp_get_root_domain());
     }
 }
开发者ID:nayabbukhari,项目名称:circulocristiano,代码行数:31,代码来源:class-ms-addon-buddypress.php


示例9: bp_save_profile_data

 /**
  * Saves Buddypress profile data.
  *
  * @uses WP_CRM_Core::wp_crm_save_user_data()
  * @param array $data. Request (POST,GET)
  * @author peshkov@UD
  */
 static function bp_save_profile_data($data)
 {
     global $bp;
     if (empty($data['bp']) || empty($data['user_id'])) {
         return;
     }
     //* Set necessary variables */
     $user_id = $data['user_id'];
     $user_data = $data['wp_crm']['user_data'];
     $data = $data['bp'];
     $errors = false;
     $posted_field_ids = array();
     $is_required = array();
     //* Set xprofile full name from display_name */
     $display_name = WP_CRM_F::get_first_value($user_data['display_name']);
     if (!empty($display_name)) {
         $fullname_field_name = bp_xprofile_fullname_field_name();
         $fullname_field_id = xprofile_get_field_id_from_name($fullname_field_name);
         $data["field_{$fullname_field_id}"] = $display_name;
     }
     //* Get all posted field ids */
     foreach ($data as $name => $value) {
         $field_id = str_replace(array('field_', '_day', '_month', '_year'), '', $name);
         array_push($posted_field_ids, $field_id);
     }
     $posted_field_ids = array_unique($posted_field_ids);
     //* Validate the field */
     foreach ($posted_field_ids as $field_id) {
         if (!isset($data['field_' . $field_id])) {
             if (!empty($data['field_' . $field_id . '_day']) && !empty($data['field_' . $field_id . '_month']) && !empty($data['field_' . $field_id . '_year'])) {
                 /* Concatenate the values */
                 $date_value = $data['field_' . $field_id . '_day'] . ' ' . $data['field_' . $field_id . '_month'] . ' ' . $data['field_' . $field_id . '_year'];
                 /* Turn the concatenated value into a timestamp */
                 $data['field_' . $field_id] = date('Y-m-d H:i:s', strtotime($date_value));
             }
         }
         $is_required[$field_id] = xprofile_check_is_required_field($field_id);
         if ($is_required[$field_id] && empty($data['field_' . $field_id])) {
             $errors = true;
         }
     }
     //** There are errors */
     if ($errors) {
         WP_CRM_F::add_message(__('Please make sure you fill in all required Buddypress fields in this profile field group before saving.', ud_get_wp_crm()->domain), 'bad');
         //** No errors */
     } else {
         //** Now we've checked for required fields, lets save the values. */
         foreach ($posted_field_ids as $field_id) {
             //** 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. */
             if (empty($data['field_' . $field_id])) {
                 $value = array();
             } else {
                 $value = $data['field_' . $field_id];
             }
             if (!xprofile_set_field_data($field_id, $user_id, $value, $is_required[$field_id])) {
                 $errors = true;
             } else {
                 do_action('xprofile_profile_field_data_updated', $field_id, $value);
             }
         }
         //** Set the feedback message if we have error */
         if ($errors) {
             WP_CRM_F::add_message(__('There was a problem updating some of Buddypress profile information, please try again.', ud_get_wp_crm()->domain), 'bad');
         }
     }
 }
开发者ID:Finzy,项目名称:stageDB,代码行数:74,代码来源:buddypress.php


示例10: bp_core_screen_signup

function bp_core_screen_signup() {
	global $bp, $wpdb;

	if ( $bp->current_component != BP_REGISTER_SLUG )
		return false;

	/* If the user is logged in, redirect away from here */
	if ( is_user_logged_in() )
		bp_core_redirect( $bp->root_domain );

	/* If signups are disabled, just re-direct */
	if ( !bp_get_signup_allowed() )
		bp_core_redirect( $bp->root_domain );

	$bp->signup->step = 'request-details';

	/* If the signup page is submitted, validate and save */
	if ( isset( $_POST['signup_submit'] ) ) {

		/* Check the nonce */
		check_admin_referer( 'bp_new_signup' );

		require_once( ABSPATH . WPINC . '/registration.php' );

		/* Check the base account details for problems */
		$account_details = bp_core_validate_user_signup( $_POST['signup_username'], $_POST['signup_email'] );

		/* If there are errors with account details, set them for display */
		if ( !empty( $account_details['errors']->errors['user_name'] ) )
			$bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];

		if ( !empty( $account_details['errors']->errors['user_email'] ) )
			$bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];

		/* Check that both password fields are filled in */
		if ( empty( $_POST['signup_password'] ) || empty( $_POST['signup_password_confirm'] ) )
			$bp->signup->errors['signup_password'] = __( 'Please make sure you enter your password twice', 'buddypress' );

		/* Check that the passwords match */
		if ( ( !empty( $_POST['signup_password'] ) && !empty( $_POST['signup_password_confirm'] ) ) && $_POST['signup_password'] != $_POST['signup_password_confirm'] )
			$bp->signup->errors['signup_password'] = __( 'The passwords you entered do not match.', 'buddypress' );

		$bp->signup->username = $_POST['signup_username'];
		$bp->signup->email = $_POST['signup_email'];

		/* Now we've checked account details, we can check profile information */
		if ( function_exists( 'xprofile_check_is_required_field' ) ) {

			/* Make sure hidden field is passed and populated */
			if ( isset( $_POST['signup_profile_field_ids'] ) && !empty( $_POST['signup_profile_field_ids'] ) ) {

				/* Let's compact any profile field info into an array */
				$profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );

				/* Loop through the posted fields formatting any datebox values then validate the field */
				foreach ( (array) $profile_field_ids as $field_id ) {
					if ( !isset( $_POST['field_' . $field_id] ) ) {
						if ( isset( $_POST['field_' . $field_id . '_day'] ) )
							$_POST['field_' . $field_id] = strtotime( $_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year'] );
					}

					/* Create errors for required fields without values */
					if ( xprofile_check_is_required_field( $field_id ) && empty( $_POST['field_' . $field_id] ) )
						$bp->signup->errors['field_' . $field_id] = __( 'This is a required field', 'buddypress' );
				}

			/* This situation doesn't naturally occur so bounce to website root */
			} else {
				bp_core_redirect( $bp->root_domain );
			}
		}

		/* Finally, let's check the blog details, if the user wants a blog and blog creation is enabled */
		if ( isset( $_POST['signup_with_blog'] ) ) {
			$active_signup = $bp->site_options['registration'];

			if ( 'blog' == $active_signup || 'all' == $active_signup ) {
				$blog_details = bp_core_validate_blog_signup( $_POST['signup_blog_url'], $_POST['signup_blog_title'] );

				/* If there are errors with blog details, set them for display */
				if ( !empty( $blog_details['errors']->errors['blogname'] ) )
					$bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];

				if ( !empty( $blog_details['errors']->errors['blog_title'] ) )
					$bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0];
			}
		}

		do_action( 'bp_signup_validate' );

		/* Add any errors to the action for the field in the template for display. */
		if ( !empty( $bp->signup->errors ) ) {
			foreach ( (array)$bp->signup->errors as $fieldname => $error_message )
				add_action( 'bp_' . $fieldname . '_errors', create_function( '', 'echo "<div class=\"error\">' . $error_message . '</div>";' ) );
		} else {
			$bp->signup->step = 'save-details';

			/* No errors! Let's register those deets. */
			$active_signup = $bp->site_options['registration'];

//.........这里部分代码省略.........
开发者ID:n-sane,项目名称:zaroka,代码行数:101,代码来源:bp-core-signup.php


示例11: bp_ajax_submit_register_form

function bp_ajax_submit_register_form()
{
    global $bp;
    // Check the nonce
    check_admin_referer('bp_new_signup');
    // Check the base account details for problems
    $account_details = bp_core_validate_user_signup($_POST['signup_username'], $_POST['signup_email']);
    // If there are errors with account details, set them for display
    if (!empty($account_details['errors']->errors['user_name'])) {
        $bp->signup->errors['signup_username'] = $account_details['errors']->errors['user_name'][0];
    }
    if (!empty($account_details['errors']->errors['user_email'])) {
        $bp->signup->errors['signup_email'] = $account_details['errors']->errors['user_email'][0];
    }
    // Check that both password fields are filled in
    if (empty($_POST['signup_password']) || empty($_POST['signup_password_confirm'])) {
        $bp->signup->errors['signup_password'] = __('Please make sure you enter your password twice', 'buddypress');
    }
    // Check that the passwords match
    if (!empty($_POST['signup_password']) && !empty($_POST['signup_password_confirm']) && $_POST['signup_password'] != $_POST['signup_password_confirm']) {
        $bp->signup->errors['signup_password'] = __('The passwords you entered do not match.', 'buddypress');
    }
    $bp->signup->username = $_POST['signup_username'];
    $bp->signup->email = $_POST['signup_email'];
    // Now we've checked account details, we can check profile information
    if (bp_is_active('xprofile')) {
        // Make sure hidden field is passed and populated
        if (isset($_POST['signup_profile_field_ids']) && !empty($_POST['signup_profile_field_ids'])) {
            // Let's compact any profile field info into an array
            $profile_field_ids = explode(',', $_POST['signup_profile_field_ids']);
            // Loop through the posted fields formatting any datebox values then validate the field
            foreach ((array) $profile_field_ids as $field_id) {
                if (!isset($_POST['field_' . $field_id])) {
                    if (!empty($_POST['field_' . $field_id . '_day']) && !empty($_POST['field_' . $field_id . '_month']) && !empty($_POST['field_' . $field_id . '_year'])) {
                        $_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']));
                    }
                }
                // Create errors for required fields without values
                if (xprofile_check_is_required_field($field_id) && empty($_POST['field_' . $field_id])) {
                    $bp->signup->errors['field_' . $field_id] = __('This is a required field', 'buddypress');
                }
            }
            // This situation doesn't naturally occur so bounce to website root
        } else {
            bp_core_redirect(bp_get_root_domain());
        }
    }
    // Finally, let's check the blog details, if the user wants a blog and blog creation is enabled
    if (isset($_POST['signup_with_blog'])) {
        $active_signup = $bp->site_options['registration'];
        if ('blog' == $active_signup || 'all' == $active_signup) {
            $blog_details = bp_core_validate_blog_signup($_POST['signup_blog_url'], $_POST['signup_blog_title']);
            // If there are errors with blog details, set them for display
            if (!empty($blog_details['errors']->errors['blogname'])) {
                $bp->signup->errors['signup_blog_url'] = $blog_details['errors']->errors['blogname'][0];
            }
            if (!empty($blog_details['errors']->errors['blog_title'])) {
                $bp->signup->errors['signup_blog_title'] = $blog_details['errors']->errors['blog_title'][0];
            }
        }
    }
    do_action('bp_signup_validate');
    // Add any errors to the action for the field in the template for display.
    if (!empty($bp->signup->errors)) {
        $response['status'] = 'error';
        $response['errors'] = $bp->signup->errors;
        echo json_encode($response);
        exit;
        /*foreach ( (array) $bp->signup->errors as $fieldname => $error_message ) {
        			// addslashes() and stripslashes() to avoid create_ 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP xprofile_format_profile_field函数代码示例发布时间:2022-05-23
下一篇:
PHP xpath_new_context函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap