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


PHP bp_xprofile_get_visibility_levels函数代码示例

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


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

示例1: render_admin_form


//.........这里部分代码省略.........
" name="saveField" id="saveField" style="font-weight: bold" class="button-primary" />
											</div>
											<div id="delete-action">
												<a href="users.php?page=bp-profile-setup" class="deletion"><?php 
        _e('Cancel', 'buddypress');
        ?>
</a>
											</div>
											<?php 
        wp_nonce_field('xprofile_delete_option');
        ?>
											<div class="clear"></div>
										</div>
									</div>
								</div>
							</div>

							<?php 
        /* Field 1 is the fullname field, which cannot have custom visibility */
        ?>
							<?php 
        if (1 != $this->id) {
            ?>

								<div class="postbox">
									<h3><label for="default-visibility"><?php 
            _e('Default Visibility', 'buddypress');
            ?>
</label></h3>
									<div class="inside">
										<ul>

											<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>

												<li>
													<input type="radio" id="default-visibility[<?php 
                echo esc_attr($level['id']);
                ?>
]" name="default-visibility" value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                checked($this->default_visibility, $level['id']);
                ?>
 />
													<label for="default-visibility[<?php 
                echo esc_attr($level['id']);
                ?>
]"><?php 
                echo esc_html($level['label']);
                ?>
</label>
												</li>

											<?php 
            }
            ?>

										</ul>
									</div>
								</div>

								<div class="postbox">
									<h3><label for="allow-custom-visibility"><?php 
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:67,代码来源:bp-xprofile-classes.php

示例2: filter_global_visibility_from_radio_buttons

    /**
     * Filter 'global' visibility levels from radio buttons.
     *
     * @since  1.0
     *
     * @param string 	$retval
     * @param array   	$request
     * @param array   	$args
     *
     * @return array
     */
    public function filter_global_visibility_from_radio_buttons($retval, $r, $args)
    {
        // Empty return value, filled in below if a valid field ID is found
        $retval = '';
        // Only do-the-do if there's a valid field ID
        if (!empty($r['field_id'])) {
            // Start the output buffer
            ob_start();
            // Output anything before
            echo $r['before'];
            ?>

			<?php 
            if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
                ?>

				<?php 
                foreach (bp_xprofile_get_visibility_levels() as $level) {
                    ?>

					<?php 
                    if ($level['id'] != 'global') {
                        ?>

						<?php 
                        printf($r['before_radio'], esc_attr($level['id']));
                        ?>

						<label for="<?php 
                        echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                        ?>
">
							<input type="radio" id="<?php 
                        echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                        ?>
" name="<?php 
                        echo esc_attr('field_' . $r['field_id'] . '_visibility');
                        ?>
" value="<?php 
                        echo esc_attr($level['id']);
                        ?>
" <?php 
                        checked($level['id'], bp_get_the_profile_field_visibility_level());
                        ?>
 />
							<span class="field-visibility-text"><?php 
                        echo esc_html($level['label']);
                        ?>
</span>
						</label>

						<?php 
                        echo $r['after_radio'];
                        ?>

					<?php 
                    }
                    ?>

				<?php 
                }
                ?>

			<?php 
            }
            // Output anything after
            echo $r['after'];
            // Get the output buffer and empty it
            $retval = ob_get_clean();
        }
        return $retval;
    }
开发者ID:nightbook,项目名称:buddypress-admin-global-profile-fields,代码行数:83,代码来源:bp-admin-only-profile-fields.php

示例3: xprofile_set_field_visibility_level

/**
 * Set the visibility level for this field
 *
 * @param int $field_id The ID of the xprofile field
 * @param int $user_id The ID of the user to whom the data belongs
 * @param string $visibility_level
 * @return bool True on success
 */
function xprofile_set_field_visibility_level($field_id = 0, $user_id = 0, $visibility_level = '')
{
    if (empty($field_id) || empty($user_id) || empty($visibility_level)) {
        return false;
    }
    // Check against a whitelist
    $allowed_values = bp_xprofile_get_visibility_levels();
    if (!array_key_exists($visibility_level, $allowed_values)) {
        return false;
    }
    // Stored in an array in usermeta
    $current_visibility_levels = bp_get_user_meta($user_id, 'bp_xprofile_visibility_levels', true);
    if (!$current_visibility_levels) {
        $current_visibility_levels = array();
    }
    $current_visibility_levels[$field_id] = $visibility_level;
    return bp_update_user_meta($user_id, 'bp_xprofile_visibility_levels', $current_visibility_levels);
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:26,代码来源:bp-xprofile-functions.php

示例4: bp_profile_get_settings_visibility_select

/**
 * Return the XProfile field visibility select list for settings.
 *
 * @since 2.0.0
 *
 * @param array|string $args {
 *    Args for the select list.
 *
 *    @type int    $field_id ID of the field to render.
 *    @type string $before   Markup to render before the field.
 *    @type string $before_controls  markup before form controls.
 *    @type string $after    Markup to render after the field.
 *    @type string $after_controls Markup after the form controls.
 *    @type string $class    Class to apply to the field markup.
 *    @type string $label_class Class to apply for the label element.
 *    @type string $notoggle_tag Markup element to use for notoggle tag.
 *    @type string $notoggle_class Class to apply to the notoggle element.
 * }
 * @return string $retval
 */
function bp_profile_get_settings_visibility_select($args = '')
{
    // Parse optional arguments.
    $r = bp_parse_args($args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '', 'before_controls' => '', 'after' => '', 'after_controls' => '', 'class' => 'bp-xprofile-visibility', 'label_class' => 'bp-screen-reader-text', 'notoggle_tag' => 'span', 'notoggle_class' => 'field-visibility-settings-notoggle'), 'xprofile_settings_visibility_select');
    // Empty return value, filled in below if a valid field ID is found.
    $retval = '';
    // Only do-the-do if there's a valid field ID.
    if (!empty($r['field_id'])) {
        // Start the output buffer.
        ob_start();
        // Output anything before.
        echo $r['before'];
        ?>

			<?php 
        if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
            ?>

			<?php 
            echo $r['before_controls'];
            ?>

				<label for="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility" class="<?php 
            echo esc_attr($r['label_class']);
            ?>
"><?php 
            /* translators: accessibility text */
            _e('Select visibility', 'buddypress');
            ?>
</label>
				<select class="<?php 
            echo esc_attr($r['class']);
            ?>
" name="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility" id="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility">

					<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>

						<option value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                selected($level['id'], bp_get_the_profile_field_visibility_level());
                ?>
><?php 
                echo esc_html($level['label']);
                ?>
</option>

					<?php 
            }
            ?>

				</select>

			<?php 
            echo $r['after_controls'];
            ?>

			<?php 
        } else {
            ?>

				<<?php 
            echo esc_html($r['notoggle_tag']);
            ?>
 class="<?php 
            echo esc_attr($r['notoggle_class']);
            ?>
"><?php 
//.........这里部分代码省略.........
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:101,代码来源:bp-xprofile-template.php

示例5: xprofile_admin_manage_field

/**
 * Handles the adding or editing of profile field data for a user.
 *
 * @param int      $group_id ID of the group.
 * @param int|null $field_id ID of the field being managed.
 */
function xprofile_admin_manage_field($group_id, $field_id = null)
{
    global $wpdb, $message, $groups;
    $bp = buddypress();
    if (is_null($field_id)) {
        $field = new BP_XProfile_Field();
    } else {
        $field = xprofile_get_field($field_id);
    }
    $field->group_id = $group_id;
    if (isset($_POST['saveField'])) {
        if (BP_XProfile_Field::admin_validate()) {
            $field->is_required = $_POST['required'];
            $field->type = $_POST['fieldtype'];
            $field->name = $_POST['title'];
            if (!empty($_POST['description'])) {
                $field->description = $_POST['description'];
            } else {
                $field->description = '';
            }
            if (!empty($_POST["sort_order_{$field->type}"])) {
                $field->order_by = $_POST["sort_order_{$field->type}"];
            }
            $field->field_order = $wpdb->get_var($wpdb->prepare("SELECT field_order FROM {$bp->profile->table_name_fields} WHERE id = %d", $field_id));
            if (empty($field->field_order) || is_wp_error($field->field_order)) {
                $field->field_order = (int) $wpdb->get_var($wpdb->prepare("SELECT max(field_order) FROM {$bp->profile->table_name_fields} WHERE group_id = %d", $group_id));
                $field->field_order++;
            }
            // For new profile fields, set the $field_id. For existing profile
            // fields, this will overwrite $field_id with the same value.
            $field_id = $field->save();
            if (empty($field_id)) {
                $message = __('There was an error saving the field. Please try again.', 'buddypress');
                $type = 'error';
            } else {
                $message = __('The field was saved successfully.', 'buddypress');
                $type = 'success';
                // @todo remove these old options
                if (1 == $field_id) {
                    bp_update_option('bp-xprofile-fullname-field-name', $field->name);
                }
                // Set member types.
                if (isset($_POST['has-member-types'])) {
                    $member_types = array();
                    if (isset($_POST['member-types'])) {
                        $member_types = stripslashes_deep($_POST['member-types']);
                    }
                    $field->set_member_types($member_types);
                }
                // Validate default visibility.
                if (!empty($_POST['default-visibility']) && in_array($_POST['default-visibility'], wp_list_pluck(bp_xprofile_get_visibility_levels(), 'id'))) {
                    bp_xprofile_update_field_meta($field_id, 'default_visibility', $_POST['default-visibility']);
                }
                // Validate custom visibility.
                if (!empty($_POST['allow-custom-visibility']) && in_array($_POST['allow-custom-visibility'], array('allowed', 'disabled'))) {
                    bp_xprofile_update_field_meta($field_id, 'allow_custom_visibility', $_POST['allow-custom-visibility']);
                }
                // Validate signup.
                if (!empty($_POST['signup-position'])) {
                    bp_xprofile_update_field_meta($field_id, 'signup_position', (int) $_POST['signup-position']);
                } else {
                    bp_xprofile_delete_meta($field_id, 'field', 'signup_position');
                }
                /**
                 * Fires at the end of the process to save a field for a user, if successful.
                 *
                 * @since 1.0.0
                 *
                 * @param BP_XProfile_Field $field Current BP_XProfile_Field object.
                 */
                do_action('xprofile_fields_saved_field', $field);
                $groups = bp_xprofile_get_groups();
            }
            unset($_GET['mode']);
            xprofile_admin($message, $type);
        } else {
            $field->render_admin_form($message);
        }
    } else {
        $field->render_admin_form();
    }
}
开发者ID:boonebgorges,项目名称:BuddyPress-1,代码行数:88,代码来源:bp-xprofile-admin.php

示例6: render_admin_form


//.........这里部分代码省略.........
            ?>

						<?php 
            $this->render_admin_form_children();
            ?>

					<?php 
        } else {
            ?>

						<input type="hidden" name="required" id="required" value="1" />
						<input type="hidden" name="fieldtype" id="fieldtype" value="textbox" />

					<?php 
        }
        ?>

					<?php 
        /* The fullname field cannot be hidden */
        ?>
					<?php 
        if (1 != $this->id) {
            ?>

						<div id="titlediv">

							<div id="titlewrap">
								<h3><label for="default-visibility"><?php 
            _e("Default Visibility", 'buddypress');
            ?>
</label></h3>
								<ul>
								<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>
									<li><input type="radio" name="default-visibility" value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                checked($this->default_visibility, $level['id']);
                ?>
> <?php 
                echo esc_html($level['label']);
                ?>
</li>
								<?php 
            }
            ?>
								</ul>
							</div>

							<div id="titlewrap">
								<h3><label for="allow-custom-visibility"><?php 
            _e("Per-Member Visibility", 'buddypress');
            ?>
</label></h3>
								<ul>
									<li><input type="radio" name="allow-custom-visibility" value="allowed" <?php 
            checked($this->allow_custom_visibility, 'allowed');
            ?>
> <?php 
            _e("Let members change the this field's visibility", 'buddypress');
            ?>
</li>

									<li><input type="radio" name="allow-custom-visibility" value="disabled" <?php 
开发者ID:vsalx,项目名称:rattieinfo,代码行数:67,代码来源:bp-xprofile-classes.php

示例7: visibility_metabox

    /**
     * Private method used to output field visibility metaboxes.
     *
     * @since 2.3.0
     *
     * @return void If default field id 1.
     */
    private function visibility_metabox()
    {
        // Default field cannot have custom visibility.
        if (true === $this->is_default_field()) {
            return;
        }
        ?>

		<div class="postbox">
			<h2><label for="default-visibility"><?php 
        esc_html_e('Visibility', 'buddypress');
        ?>
</label></h2>
			<div class="inside">
				<div>
					<select name="default-visibility" id="default-visibility">

						<?php 
        foreach (bp_xprofile_get_visibility_levels() as $level) {
            ?>

							<option value="<?php 
            echo esc_attr($level['id']);
            ?>
" <?php 
            selected($this->get_default_visibility(), $level['id']);
            ?>
>
								<?php 
            echo esc_html($level['label']);
            ?>
							</option>

						<?php 
        }
        ?>

					</select>
				</div>

				<div>
					<ul>
						<li>
							<input type="radio" id="allow-custom-visibility-allowed" name="allow-custom-visibility" value="allowed" <?php 
        checked($this->get_allow_custom_visibility(), 'allowed');
        ?>
 />
							<label for="allow-custom-visibility-allowed"><?php 
        esc_html_e('Allow members to override', 'buddypress');
        ?>
</label>
						</li>
						<li>
							<input type="radio" id="allow-custom-visibility-disabled" name="allow-custom-visibility" value="disabled" <?php 
        checked($this->get_allow_custom_visibility(), 'disabled');
        ?>
 />
							<label for="allow-custom-visibility-disabled"><?php 
        esc_html_e('Enforce field visibility', 'buddypress');
        ?>
</label>
						</li>
					</ul>
				</div>
			</div>
		</div>

		<?php 
    }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:76,代码来源:class-bp-xprofile-field.php

示例8: bp_profile_get_settings_visibility_select

/**
 * Return the XProfile field visibility select list for settings
 *
 * @since BuddyPress (2.0.0)
 */
function bp_profile_get_settings_visibility_select($args = '')
{
    // Parse optional arguments
    $r = bp_parse_args($args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '', 'after' => '', 'class' => 'bp-xprofile-visibility'), 'xprofile_settings_visibility_select');
    // Empty return value, filled in below if a valid field ID is found
    $retval = '';
    // Only do-the-do if there's a valid field ID
    if (!empty($r['field_id'])) {
        // Start the output buffer
        ob_start();
        // Output anything before
        echo $r['before'];
        ?>

			<?php 
        if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
            ?>

				<select class="<?php 
            echo esc_attr($r['class']);
            ?>
" name="<?php 
            echo esc_attr('field_' . $r['field_id']);
            ?>
_visibility">

					<?php 
            foreach (bp_xprofile_get_visibility_levels() as $level) {
                ?>

						<option value="<?php 
                echo esc_attr($level['id']);
                ?>
" <?php 
                selected($level['id'], bp_get_the_profile_field_visibility_level());
                ?>
><?php 
                echo esc_html($level['label']);
                ?>
</option>

					<?php 
            }
            ?>

				</select>

			<?php 
        } else {
            ?>

				<span class="field-visibility-settings-notoggle" title="<?php 
            esc_attr_e("This field's visibility cannot be changed.", 'buddypress');
            ?>
"><?php 
            bp_the_profile_field_visibility_level_label();
            ?>
</span>

			<?php 
        }
        // Output anything after
        echo $r['after'];
        // Get the output buffer and empty it
        $retval = ob_get_clean();
    }
    // Output the dropdown list
    return apply_filters('bp_profile_settings_visibility_select', $retval, $r, $args);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:74,代码来源:bp-xprofile-template.php

示例9: bp_profile_get_visibility_radio_buttons

/**
 * Return the field visibility radio buttons
 */
function bp_profile_get_visibility_radio_buttons()
{
    $html = '<ul class="radio">';
    foreach (bp_xprofile_get_visibility_levels() as $level) {
        $checked = $level['id'] == bp_get_the_profile_field_visibility_level() ? ' checked="checked" ' : '';
        $html .= '<li><label for="see-field_' . esc_attr($level['id']) . '"><input type="radio" id="see-field_' . esc_attr($level['id']) . '" name="field_' . bp_get_the_profile_field_id() . '_visibility" value="' . esc_attr($level['id']) . '"' . $checked . ' /> ' . esc_html($level['label']) . '</label></li>';
    }
    $html .= '</ul>';
    return apply_filters('bp_profile_get_visibility_radio_buttons', $html);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:13,代码来源:bp-xprofile-template.php

示例10: ez_bp_profile_get_visibility_radio_buttons

        /**
         * Return the field visibility radio buttons
         */
        function ez_bp_profile_get_visibility_radio_buttons($arr_args = '')
        {
            global $field;
            $arr_ev_levels_processed = $this->_arr_ev_levels_processed;
            $str_ev_level = $this->ez_bp_get_the_profile_field_visibility_level();
            $str_field_edit = $arr_ev_levels_processed[$str_ev_level]['edit'];
            $str_field_viz = $arr_ev_levels_processed[$str_ev_level]['visible'];
            // Parse optional arguments
            $r = bp_parse_args($arr_args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '<ul class="radio">', 'after' => '</ul>', 'before_radio' => '<li>', 'after_radio' => '</li>', 'class' => 'bp-xprofile-visibility'), 'xprofile_visibility_radio_buttons');
            // Empty return value, filled in below if a valid field ID is found
            $retval = '';
            // Only do-the-do if there's a valid field ID
            if (!empty($r['field_id'])) {
                // Start the output buffer
                ob_start();
                // Output anything before
                echo $r['before'];
                ?>

			<?php 
                if (bp_current_user_can('bp_xprofile_change_field_visibility')) {
                    ?>

				<?php 
                    $str_label_needle = ':';
                    foreach (bp_xprofile_get_visibility_levels() as $level) {
                        $str_edit = $this->get_level_edit($level['id']);
                        $str_viz = $this->get_level_visible($level['id']);
                        if ($str_edit == $str_field_edit) {
                            echo $r['before_radio'];
                            ?>
					  
					<label for="<?php 
                            echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                            ?>
">
						<input type="radio" id="<?php 
                            echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']);
                            ?>
" name="<?php 
                            echo esc_attr('field_' . $r['field_id'] . '_visibility');
                            ?>
" value="<?php 
                            echo esc_attr($level['id']);
                            ?>
" <?php 
                            checked($level['id'], bp_get_the_profile_field_visibility_level());
                            ?>
 />
						<span class="field-visibility-text"><?php 
                            echo esc_html($this->ez_bp_get_the_profile_field_visibility_level_label($level['id']));
                            ?>
</span>
					</label>

					<?php 
                            echo $r['after_radio'];
                        }
                        ?>

				<?php 
                    }
                    ?>

			<?php 
                }
                // Output anything after
                echo $r['after'];
                // Get the output buffer and empty it
                $retval = ob_get_clean();
            }
            return apply_filters('bp_profile_get_visibility_radio_buttons', $retval, $r, $arr_args);
        }
开发者ID:WPezClasses,项目名称:class-wp-ezclasses-buddypress-editability-visibility-1,代码行数:76,代码来源:class-wp-ezclasses-buddypress-editability-visibility-1.php


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