当前位置: 首页>>代码示例>>PHP>>正文


PHP BP_XProfile_Field::get_edit_html方法代码示例

本文整理汇总了PHP中BP_XProfile_Field::get_edit_html方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_XProfile_Field::get_edit_html方法的具体用法?PHP BP_XProfile_Field::get_edit_html怎么用?PHP BP_XProfile_Field::get_edit_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_XProfile_Field的用法示例。


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

示例1: xprofile_edit


//.........这里部分代码省略.........
                        // Create an empty profile data object and populate it with new data
                        $profile_data = new BP_Xprofile_ProfileData();
                        $profile_data->field_id = $group->fields[$j]->id;
                        $profile_data->user_id = $userdata->ID;
                        $profile_data->last_updated = time();
                        // If the $post_field_string we set up earlier is not null, then this is a datebox
                        // we need to concatenate each of the three select boxes for day, month and year into
                        // one value.
                        if ($post_field_string != null) {
                            // Concatenate the values.
                            $date_value = $_POST['field_' . $group->fields[$j]->id . '_day'] . $_POST['field_' . $group->fields[$j]->id . '_month'] . $_POST['field_' . $group->fields[$j]->id . '_year'];
                            // Turn the concatenated value into a timestamp
                            $profile_data->value = strtotime($date_value);
                        } else {
                            // Checkbox and multi select box fields will submit an array as their value
                            // so we need to serialize them before saving to the DB.
                            if (is_array($current_field)) {
                                $current_field = serialize($current_field);
                            }
                            $profile_data->value = $current_field;
                        }
                        // Finally save the value to the database.
                        if (!$profile_data->save()) {
                            $field->message = __('There was a problem saving changes to this field, please try again.', 'buddypress');
                        } else {
                            $field->data->value = $profile_data->value;
                        }
                    }
                }
            }
            // Each field object comes with HTML that can be rendered to edit that field.
            // We just need to render that to the page by adding it to the $list_html variable
            // that will be rendered when the field loop has finished.
            $list_html .= '<li>' . $field->get_edit_html() . '</li>';
        }
        // Now that the loop has finished put the final touches on the HTML including the submit button.
        $list_html .= '</ul>';
        $list_html .= '<p class="submit">
								<input type="submit" name="save" id="save" value="' . __('Save Changes &raquo;', 'buddypress') . '" />
							   </p>';
        $list_html .= wp_nonce_field('bp_xprofile_edit');
        // If the user submitted the form to save new values, and there were errors, make sure we display them.
        if ($errors && isset($_POST['save'])) {
            $type = 'error';
            $message = __('There were problems saving your information. Please fix the following:<br />', 'buddypress');
            for ($i = 0; $i < count($errors); $i++) {
                $message .= $errors[$i];
            }
            // If there were no errors then we can display a nice "Changes saved." message.
        } else {
            if (!$errors && isset($_POST['save'])) {
                $type = 'success';
                $message = __('Changes saved.', 'buddypress');
                // Record in activity stream
                xprofile_record_activity(array('item_id' => $group->id, 'component_name' => 'profile', 'component_action' => 'updated_profile', 'is_private' => 0));
                do_action('xprofile_updated_profile', $group->id);
            }
        }
    } else {
        ?>
				<div id="message" class="error fade">
					<p><?php 
        _e('That group does not exist.', 'buddypress');
        ?>
</p>
				</div>
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:67,代码来源:bp-xprofile.php


注:本文中的BP_XProfile_Field::get_edit_html方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。