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

PHP xprofile_set_field_visibility_level函数代码示例

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

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



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

示例1: bp_xprofile_action_settings

/**
 * Handles the saving of xprofile field visibilities
 *
 * @since BuddyPress (1.9)
 */
function bp_xprofile_action_settings()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if no submit action
    if (!isset($_POST['xprofile-settings-submit'])) {
        return;
    }
    // Bail if not in settings
    if (!bp_is_user_settings_profile()) {
        return;
    }
    // 404 if there are any additional action variables attached
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    // Nonce check
    check_admin_referer('bp_xprofile_settings');
    do_action('bp_xprofile_settings_before_save');
    /** Save ******************************************************************/
    // Only save if there are field ID's being posted
    if (!empty($_POST['field_ids'])) {
        // Get the POST'ed field ID's
        $posted_field_ids = explode(',', $_POST['field_ids']);
        // Save the visibility settings
        foreach ($posted_field_ids as $field_id) {
            $visibility_level = 'public';
            if (!empty($_POST['field_' . $field_id . '_visibility'])) {
                $visibility_level = $_POST['field_' . $field_id . '_visibility'];
            }
            xprofile_set_field_visibility_level($field_id, bp_displayed_user_id(), $visibility_level);
        }
    }
    /** Other *****************************************************************/
    do_action('bp_xprofile_settings_after_save');
    // Redirect to the root domain
    bp_core_redirect(bp_displayed_user_domain() . bp_get_settings_slug() . '/profile');
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:46,代码来源:bp-xprofile-actions.php


示例2: test_fetch_visibility_level

 /**
  * @group fetch_visibility_level
  */
 public function test_fetch_visibility_level()
 {
     $u = $this->factory->user->create();
     $g = $this->factory->xprofile_group->create();
     $f = $this->factory->xprofile_field->create(array('field_group_id' => $g));
     $f_obj = new BP_XProfile_Field($f);
     $fields = array(0 => new stdClass());
     $fields[0]->id = $f;
     $fields[0]->name = $f_obj->name;
     $fields[0]->description = $f_obj->description;
     $fields[0]->type = $f_obj->type;
     $fields[0]->group_id = $f_obj->group_id;
     $fields[0]->is_required = $f_obj->is_required;
     $fields[0]->data = new stdClass();
     $fields[0]->data->value = 'foo';
     $fields[0]->data->id = 123;
     // custom visibility enabled, but no fallback
     bp_xprofile_update_meta($f, 'field', 'default_visibility', 'adminsonly');
     bp_xprofile_update_meta($f, 'field', 'allow_custom_visibility', 'enabled');
     $found = BP_XProfile_Group::fetch_visibility_level($u, $fields);
     $expected = $fields;
     $expected[0]->visibility_level = 'adminsonly';
     $this->assertSame($expected, $found);
     // custom visibility enabled, with user-provided value
     bp_xprofile_update_meta($f, 'field', 'default_visibility', 'adminsonly');
     bp_xprofile_update_meta($f, 'field', 'allow_custom_visibility', 'enabled');
     xprofile_set_field_visibility_level($f, $u, 'public');
     $found = BP_XProfile_Group::fetch_visibility_level($u, $fields);
     $expected = $fields;
     $expected[0]->visibility_level = 'public';
     $this->assertSame($expected, $found);
     // custom visibility disabled
     bp_xprofile_update_meta($f, 'field', 'default_visibility', 'adminsonly');
     bp_xprofile_update_meta($f, 'field', 'allow_custom_visibility', 'disabled');
     xprofile_set_field_visibility_level($f, $u, 'public');
     $found = BP_XProfile_Group::fetch_visibility_level($u, $fields);
     $expected = $fields;
     $expected[0]->visibility_level = 'adminsonly';
     $this->assertSame($expected, $found);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:43,代码来源:class-bp-xprofile-group.php


示例3: add_backcompat

 /**
  * Create a WP user at signup.
  *
  * Since BP 2.0, non-multisite configurations have stored signups in
  * the same way as Multisite configs traditionally have: in the
  * wp_signups table. However, because some plugins may be looking
  * directly in the wp_users table for non-activated signups, we
  * mirror signups there by creating "phantom" users, mimicking WP's
  * default behavior.
  *
  * @since 2.0.0
  *
  * @param string $user_login    User login string.
  * @param string $user_password User password.
  * @param string $user_email    User email address.
  * @param array  $usermeta      Metadata associated with the signup.
  * @return int User id.
  */
 public static function add_backcompat($user_login = '', $user_password = '', $user_email = '', $usermeta = array())
 {
     global $wpdb;
     $user_id = wp_insert_user(array('user_login' => $user_login, 'user_pass' => $user_password, 'display_name' => sanitize_title($user_login), 'user_email' => $user_email));
     if (is_wp_error($user_id) || empty($user_id)) {
         return $user_id;
     }
     // Update the user status to '2', ie "not activated"
     // (0 = active, 1 = spam, 2 = not active).
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET user_status = 2 WHERE ID = %d", $user_id));
     // WordPress creates these options automatically on
     // wp_insert_user(), but we delete them so that inactive
     // signups don't appear in various user counts.
     delete_user_option($user_id, 'capabilities');
     delete_user_option($user_id, 'user_level');
     // Set any profile data.
     if (bp_is_active('xprofile')) {
         if (!empty($usermeta['profile_field_ids'])) {
             $profile_field_ids = explode(',', $usermeta['profile_field_ids']);
             foreach ((array) $profile_field_ids as $field_id) {
                 if (empty($usermeta["field_{$field_id}"])) {
                     continue;
                 }
                 $current_field = $usermeta["field_{$field_id}"];
                 xprofile_set_field_data($field_id, $user_id, $current_field);
                 // Save the visibility level.
                 $visibility_level = !empty($usermeta['field_' . $field_id . '_visibility']) ? $usermeta['field_' . $field_id . '_visibility'] : 'public';
                 xprofile_set_field_visibility_level($field_id, $user_id, $visibility_level);
             }
         }
     }
     /**
      * Filters the user ID for the backcompat functionality.
      *
      * @since 2.0.0
      *
      * @param int $user_id User ID being registered.
      */
     return apply_filters('bp_core_signups_add_backcompat', $user_id);
 }
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:58,代码来源:class-bp-signup.php


示例4: bp_core_activate_signup

function bp_core_activate_signup($key)
{
    global $wpdb;
    $user = false;
    // Multisite installs have their own activation routine
    if (is_multisite()) {
        $user = wpmu_activate_signup($key);
        // If there were errors, add a message and redirect
        if (!empty($user->errors)) {
            return $user;
        }
        $user_id = $user['user_id'];
        // Set any profile data
        if (bp_is_active('xprofile')) {
            if (!empty($user['meta']['profile_field_ids'])) {
                $profile_field_ids = explode(',', $user['meta']['profile_field_ids']);
                foreach ((array) $profile_field_ids as $field_id) {
                    $current_field = isset($user['meta']["field_{$field_id}"]) ? $user['meta']["field_{$field_id}"] : false;
                    if (!empty($current_field)) {
                        xprofile_set_field_data($field_id, $user_id, $current_field);
                    }
                    // Save the visibility level
                    $visibility_level = !empty($user['meta']['field_' . $field_id . '_visibility']) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public';
                    xprofile_set_field_visibility_level($field_id, $user_id, $visibility_level);
                }
            }
        }
    } else {
        // Get the user_id based on the $key
        $user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'activation_key' AND meta_value = %s", $key));
        if (empty($user_id)) {
            return new WP_Error('invalid_key', __('Invalid activation key', 'buddypress'));
        }
        // Change the user's status so they become active
        if (!$wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET user_status = 0 WHERE ID = %d", $user_id))) {
            return new WP_Error('invalid_key', __('Invalid activation key', 'buddypress'));
        }
        // Notify the site admin of a new user registration
        wp_new_user_notification($user_id);
        // Remove the activation key meta
        delete_user_meta($user_id, 'activation_key');
    }
    // Update the display_name
    wp_update_user(array('ID' => $user_id, 'display_name' => bp_core_get_user_displayname($user_id)));
    // Set the password on multisite installs
    if (is_multisite() && !empty($user['meta']['password'])) {
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id));
    }
    do_action('bp_core_activated_user', $user_id, $key, $user);
    return $user_id;
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:51,代码来源:bp-members-functions.php


示例5: test_bp_xprofile_get_field_visibility_level_admin_override

 /**
  * @group xprofile_get_field_visibility_level
  */
 public function test_bp_xprofile_get_field_visibility_level_admin_override()
 {
     $u = $this->factory->user->create();
     $g = $this->factory->xprofile_group->create();
     $f = $this->factory->xprofile_field->create(array('field_group_id' => $g));
     bp_xprofile_update_meta($f, 'field', 'default_visibility', 'adminsonly');
     bp_xprofile_update_meta($f, 'field', 'allow_custom_visibility', 'disabled');
     xprofile_set_field_visibility_level($f, $u, 'loggedin');
     $this->assertSame('adminsonly', xprofile_get_field_visibility_level($f, $u));
 }
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:13,代码来源:functions.php


示例6: bp_core_activate_signup

/**
 * Activate a signup, as identified by an activation key.
 *
 * @param string $key Activation key.
 * @return int|bool User ID on success, false on failure.
 */
function bp_core_activate_signup($key)
{
    global $wpdb;
    $user = false;
    // Multisite installs have their own activation routine.
    if (is_multisite()) {
        $user = wpmu_activate_signup($key);
        // If there were errors, add a message and redirect.
        if (!empty($user->errors)) {
            return $user;
        }
        $user_id = $user['user_id'];
    } else {
        $signups = BP_Signup::get(array('activation_key' => $key));
        if (empty($signups['signups'])) {
            return new WP_Error('invalid_key', __('Invalid activation key.', 'buddypress'));
        }
        $signup = $signups['signups'][0];
        if ($signup->active) {
            if (empty($signup->domain)) {
                return new WP_Error('already_active', __('The user is already active.', 'buddypress'), $signup);
            } else {
                return new WP_Error('already_active', __('The site is already active.', 'buddypress'), $signup);
            }
        }
        // Password is hashed again in wp_insert_user.
        $password = wp_generate_password(12, false);
        $user_id = username_exists($signup->user_login);
        // Create the user.
        if (!$user_id) {
            $user_id = wp_create_user($signup->user_login, $password, $signup->user_email);
            // If a user ID is found, this may be a legacy signup, or one
            // created locally for backward compatibility. Process it.
        } elseif ($key == wp_hash($user_id)) {
            // Change the user's status so they become active.
            if (!$wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET user_status = 0 WHERE ID = %d", $user_id))) {
                return new WP_Error('invalid_key', __('Invalid activation key.', 'buddypress'));
            }
            bp_delete_user_meta($user_id, 'activation_key');
            $member = get_userdata($user_id);
            $member->set_role(get_option('default_role'));
            $user_already_created = true;
        } else {
            $user_already_exists = true;
        }
        if (!$user_id) {
            return new WP_Error('create_user', __('Could not create user', 'buddypress'), $signup);
        }
        // Fetch the signup so we have the data later on.
        $signups = BP_Signup::get(array('activation_key' => $key));
        $signup = isset($signups['signups']) && !empty($signups['signups'][0]) ? $signups['signups'][0] : false;
        // Activate the signup.
        BP_Signup::validate($key);
        if (isset($user_already_exists)) {
            return new WP_Error('user_already_exists', __('That username is already activated.', 'buddypress'), $signup);
        }
        // Set up data to pass to the legacy filter.
        $user = array('user_id' => $user_id, 'password' => $signup->meta['password'], 'meta' => $signup->meta);
        // Notify the site admin of a new user registration.
        wp_new_user_notification($user_id);
        if (isset($user_already_created)) {
            /**
             * Fires if the user has already been created.
             *
             * @since 1.2.2
             *
             * @param int    $user_id ID of the user being checked.
             * @param string $key     Activation key.
             * @param array  $user    Array of user data.
             */
            do_action('bp_core_activated_user', $user_id, $key, $user);
            return $user_id;
        }
    }
    // Set any profile data.
    if (bp_is_active('xprofile')) {
        if (!empty($user['meta']['profile_field_ids'])) {
            $profile_field_ids = explode(',', $user['meta']['profile_field_ids']);
            foreach ((array) $profile_field_ids as $field_id) {
                $current_field = isset($user['meta']["field_{$field_id}"]) ? $user['meta']["field_{$field_id}"] : false;
                if (!empty($current_field)) {
                    xprofile_set_field_data($field_id, $user_id, $current_field);
                }
                // Save the visibility level.
                $visibility_level = !empty($user['meta']['field_' . $field_id . '_visibility']) ? $user['meta']['field_' . $field_id . '_visibility'] : 'public';
                xprofile_set_field_visibility_level($field_id, $user_id, $visibility_level);
            }
        }
    }
    // Update the display_name.
    wp_update_user(array('ID' => $user_id, 'display_name' => bp_core_get_user_displayname($user_id)));
    // Set the password on multisite installs.
    if (!empty($user['meta']['password'])) {
        $wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET user_pass = %s WHERE ID = %d", $user['meta']['password'], $user_id));
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:bp-members-functions.php


示例7: 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);
     } elseif (isset($_POST['field_ids'])) {
         // Update profile fields.
         // 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) {
             bp_xprofile_maybe_format_datebox_post_data($field_id);
             $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.
         $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, $user_id), 'visibility' => xprofile_get_field_visibility_level($field_id, $user_id));
             // Update the field data and visibility level.
             xprofile_set_field_visibility_level($field_id, $user_id, $visibility_level);
             $field_updated = xprofile_set_field_data($field_id, $user_id, $value, $is_required[$field_id]);
             $value = xprofile_get_field_data($field_id, $user_id);
             $new_values[$field_id] = array('value' => $value, 'visibility' => xprofile_get_field_visibility_level($field_id, $user_id));
             if (!$field_updated) {
                 $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);
             }
         }
         /**
          * Fires after all XProfile fields have been saved for the current profile.
          *
          * @since 1.0.0
          * @since 2.6.0 Added $old_values and $new_values parameters.
          *
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:101,代码来源:class-bp-xprofile-user-admin.php


示例8: save_custom_fields

 /**
  * After the user was successfully created we now have the opportunity to
  * save the XProfile fields.
  *
  * @see bp-xprofile-screens.php function xprofile_screen_edit_profile()
  *
  * @since  1.0.0
  * @param  WP_User $user The new user.
  */
 public function save_custom_fields($user)
 {
     if (!bp_is_active('xprofile')) {
         return;
     }
     // 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 = wp_parse_id_list($_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) {
             $value = '';
             $visibility = 'public';
             if (!isset($_POST['field_' . $field_id])) {
                 // Build the value of date-fields.
                 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));
                 }
             }
             if (!empty($_POST['field_' . $field_id])) {
                 $value = $_POST['field_' . $field_id];
             }
             if (!empty($_POST['field_' . $field_id . '_visibility'])) {
                 $visibility = $_POST['field_' . $field_id . '_visibility'];
             }
             xprofile_set_field_visibility_level($field_id, $user->id, $visibility);
             xprofile_set_field_data($field_id, $user->id, $value, false);
         }
     }
 }
开发者ID:jsandlin85,项目名称:SkylineSports,代码行数:42,代码来源:class-ms-addon-buddypress.php


示例9: add_backcompat

 /**
  * Create a WP user at signup.
  *
  * Since BP 2.0, non-multisite configurations have stored signups in
  * the same way as Multisite configs traditionally have: in the
  * wp_signups table. However, because some plugins may be looking
  * directly in the wp_users table for non-activated signups, we
  * mirror signups there by creating "phantom" users, mimicking WP's
  * default behavior.
  *
  * @since BuddyPress (2.0.0)
  *
  * @param string $user_login User login string.
  * @param string $user_password User password.
  * @param string $user_email User email address.
  * @param array $usermeta Metadata associated with the signup.
  * @return int User id.
  */
 public static function add_backcompat($user_login = '', $user_password = '', $user_email = '', $usermeta = array())
 {
     global $wpdb;
     $errors = new WP_Error();
     $user_id = wp_insert_user(array('user_login' => $user_login, 'user_pass' => $user_password, 'display_name' => sanitize_title($user_login), 'user_email' => $user_email));
     if (is_wp_error($user_id) || empty($user_id)) {
         $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn&#8217;t register you. Please contact the <a href="mailto:%s">webmaster</a>.', 'buddypress'), bp_get_option('admin_email')));
         return $errors;
     }
     // Update the user status to '2', ie "not activated"
     // (0 = active, 1 = spam, 2 = not active)
     $wpdb->query($wpdb->prepare("UPDATE {$wpdb->users} SET user_status = 2 WHERE ID = %d", $user_id));
     // WordPress creates these options automatically on
     // wp_insert_user(), but we delete them so that inactive
     // signups don't appear in various user counts.
     delete_user_option($user_id, 'capabilities');
     delete_user_option($user_id, 'user_level');
     // Set any profile data
     if (bp_is_active('xprofile')) {
         if (!empty($usermeta['profile_field_ids'])) {
             $profile_field_ids = explode(',', $usermeta['profile_field_ids']);
             foreach ((array) $profile_field_ids as $field_id) {
                 if (empty($usermeta["field_{$field_id}"])) {
                     continue;
                 }
                 $current_field = $usermeta["field_{$field_id}"];
                 xprofile_set_field_data($field_id, $user_id, $current_field);
                 // Save the visibility level
                 $visibility_level = !empty($usermeta['field_' . $field_id . '_visibility']) ? $usermeta['field_' . $field_id . '_visibility'] : 'public';
                 xprofile_set_field_visibility_level($field_id, $user_id, $visibility_level);
             }
         }
     }
     return apply_filters('bp_core_signups_add_backcompat', $user_id);
 }
开发者ID:eresyyl,项目名称:mk,代码行数:53,代码来源:bp-members-classes.php


示例10: 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() && !bp_current_user_can('bp_moderate')) {
        return false;
    }
    // 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 = 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);
                }
                // 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, bp_displayed_user_id(), $visibility_level);
            }
            do_action('xprofile_updated_profile', bp_displayed_user_id(), $posted_field_ids, $errors);
            // Set the feedback messages
            if (!empty($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:hscale,项目名称:webento,代码行数:91,代码来源:bp-xprofile-screens.php


示例11: rtmedia_api_process_update_profile_request

 function rtmedia_api_process_update_profile_request()
 {
     $this->rtmediajsonapifunction->rtmedia_api_verfiy_token();
     $ec_empty_name_location = 120001;
     $msg_empty_name_location = esc_html__('name/location empty', 'buddypress-media');
     $ec_profile_updated = 120002;
     $msg_profile_updated = esc_html__('profile updated', 'buddypress-media');
     for ($i = 1; $i <= 12; $i++) {
         $field_str = 'field_';
         $field_str .= $i;
         $field_str_privacy = $field_str . '_privacy';
         ${$field_str} = filter_input(INPUT_POST, $field_str, FILTER_SANITIZE_STRING);
         ${$field_str_privacy} = filter_input(INPUT_POST, $field_str_privacy, FILTER_SANITIZE_STRING);
         !empty(${$field_str}) ? ${$field_str} : '';
         !empty(${$field_str_privacy}) ? ${$field_str_privacy} : 'public';
         if (1 === $i || 4 === $i) {
             $field_str_privacy = 'public';
             if (empty($field_str)) {
                 wp_send_json($this->rtmedia_api_response_object('TRUE', $ec_empty_name_location, $msg_empty_name_location));
             }
         }
         xprofile_set_field_data($i, $this->user_id, ${$field_str});
         xprofile_set_field_visibility_level($i, $this->user_id, ${$field_str_privacy});
     }
     wp_send_json($this->rtmedia_api_response_object('TRUE', $ec_profile_updated, $msg_profile_updated));
 }
开发者ID:rtCamp,项目名称:rtMedia,代码行数:26,代码来源:RTMediaJsonApi.php


示例12: insert_buddypress_data

 public static function insert_buddypress_data($bp_rows)
 {
     global $wpdb, $bp;
     require_once WP_PLUGIN_DIR . '/buddypress/bp-xprofile/bp-xprofile-functions.php';
     $table = $bp->profile->table_name_data;
     foreach ($bp_rows as $bp_row) {
         $success = xprofile_set_field_data($bp_row['field_id'], $bp_row['user_id'], $bp_row['value']);
         xprofile_set_field_visibility_level($bp_row['field_id'], $bp_row['user_id'], $bp_row['field']->default_visibility);
     }
 }
开发者ID:hansstam,项目名称:makerfaire,代码行数:10,代码来源:data.php


示例13: user_admin_load

 /**
  * Save the profile fields in Members community profile page.
  *
  * Loaded before the page is rendered, this function is processing form
  * requests.
  *
  * @access public
  * @since BuddyPress (2.0.0)
  */
 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
     } else {
         // Check to see if any new information has been submitted
         if (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);
                 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 {
                     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);
             }
             do_action('xprofile_updated_profile', $user_id, $posted_field_ids, $errors);
             // Set the feedback messages
             if (!empty($errors)) {
                 $redirect_to = add_query_arg('error', '3', $redirect_to);
             } else {
                 $redirect_to = add_query_arg('updated', '1', $redirect_to);
             }
             bp_core_redirect($redirect_to);
         }
     }
 }
开发者ID:danielcoats,项目名称:schoolpress,代码行数:85,代码来源:bp-xprofile-admin.php


示例14: bp_xprofile_action_settings

/**
 * Handles the saving of xprofile field visibilities
 *
 * @since BuddyPress (1.9.0)
 */
function bp_xprofile_action_settings()
{
    // Bail if not a POST action
    if ('POST' !== strtoupper($_SERVER['REQUEST_METHOD'])) {
        return;
    }
    // Bail if no submit action
    if (!isset($_POST['xprofile-settings-submit'])) {
        return;
    }
    // Bail if not in settings
    if (!bp_is_user_settings_profile()) {
        return;
    }
    // 404 if there are any additional action variables attached
    if (bp_action_variables()) {
        bp_do_404();
        return;
    }
    // Nonce check
    check_admin_referer('bp_xprofile_settings');
    /**
     * Fires before saving xprofile field visibilities.
     *
     * @since BuddyPress (2.0.0)
     */
    do_action('bp_xprofile_settings_before_save');
    /** Save ******************************************************************/
    // Only save if there are field ID's being posted
    if (!empty($_POST['field_ids'])) {
        // Get the POST'ed field ID's
        $posted_field_ids = explode(',', $_POST['field_ids']);
        // Backward compatibility: a bug in BP 2.0 caused only a single
        // group's field IDs to be submitted. Look for values submitted
        // in the POST request that may not appear in 'field_ids', and
        // add them to the list of IDs to save.
        foreach ($_POST as $posted_key => $posted_value) {
            preg_match('/^field_([0-9]+)_visibility$/', $posted_key, $matches);
            if (!empty($matches[1]) && !in_array($matches[1], $posted_field_ids)) {
                $posted_field_ids[] = $matches[1];
            }
        }
        // Save the visibility settings
        foreach ($posted_field_ids as $field_id) {
            $visibility_level = 'public';
            if (!empty($_POST['field_' . $field_id . '_visibility'])) {
                $visibility_level = $_POST['field_' . $field_id . '_visibility'];
            }
            xprofile_set_field_visibility_level($field_id, bp_displayed_user_id(), $visibility_level);
        }
    }
    /** Other *****************************************************************/
    /**
     * Fires after saving xprofile field visibilities.
     *
     * @since BuddyPress (2.0.0)
     */
    do_action('bp_xprofile_settings_after_save');
    // Redirect to the root domain
    bp_core_redirect(bp_displayed_user_domain() . bp_get_settings_slug() . '/profile');
}
开发者ID:AceMedia,项目名称:BuddyPress,代码行数:66,代码来源:bp-xprofile-actions.php


示例15: 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
                xp 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP xs_error函数代码示例发布时间:2022-05-23
下一篇:
PHP xprofile_set_field_data函数代码示例发布时间: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