示例#1
0
/**
 * Adjust the output of the first name/last name field to display a full name if the option is enabled.
 * If the option is enabled into the first name field, WPUM will display the first name + last name,
 * if the option is enabled into the last name field, WPUM will display the last name + first name.
 *
 * @param  string $value the value of field.
 * @param  string $field  field object.
 * @return string        output of this field.
 * @since 1.2.0
 */
function wpum_adjust_name_meta_output($value, $field)
{
    if (wpum_is_single_profile()) {
        if ($field->meta == 'first_name' && wpum_get_field_option($field->id, 'display_full_name')) {
            $value = $value . ' ' . wpum_get_user_lname(wpum_get_displayed_user_id());
        } elseif ($field->meta == 'last_name' && wpum_get_field_option($field->id, 'display_full_name')) {
            $value = $value . ' ' . wpum_get_user_fname(wpum_get_displayed_user_id());
        }
    }
    return $value;
}
示例#2
0
/**
 * Use this function to start a loop of profile fields.
 *
 * @since 1.2.0
 * @global $wpum_profile_fields
 * @param  string  $args arguments to create the loop.
 * @return boolean       whether there's any group found.
 */
function wpum_has_profile_fields($args = '')
{
    global $wpum_profile_fields;
    $defaults = array('user_id' => absint(wpum_get_displayed_user_id()), 'field_group_id' => false, 'number' => false, 'number_fields' => false, 'hide_empty_groups' => true, 'exclude_groups' => false, 'exclude_fields' => false);
    /**
     * Filters the query arguments to retrieve fields from the database.
     *
     * @since 1.2.0
     * @return array.
     */
    $args = apply_filters('wpum_has_profile_fields_query', wp_parse_args($args, $defaults));
    $wpum_profile_fields = new WPUM_Fields_Data_Template($args);
    return apply_filters('wpum_has_profile_fields', $wpum_profile_fields->has_groups(), $wpum_profile_fields);
}