本文整理匯總了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 »', '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>