Example #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, wpaam will display the first name + last name,
 * if the option is enabled into the last name field, wpaam 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 wpaam_adjust_name_meta_output($value, $field)
{
    if (wpaam_is_single_profile()) {
        if ($field->meta == 'first_name' && wpaam_get_field_option($field->id, 'display_full_name')) {
            $value = $value . ' ' . wpaam_get_user_lname(wpaam_get_displayed_user_id());
        } elseif ($field->meta == 'last_name' && wpaam_get_field_option($field->id, 'display_full_name')) {
            $value = $value . ' ' . wpaam_get_user_fname(wpaam_get_displayed_user_id());
        }
    }
    return $value;
}
Example #2
0
/**
 * Use this function to start a loop of profile fields.
 *
 * @since 1.2.0
 * @global $wpaam_profile_fields
 * @param  string  $args arguments to create the loop.
 * @return boolean       whether there's any group found.
 */
function wpaam_has_profile_fields($args = '')
{
    global $wpaam_profile_fields;
    $defaults = array('user_id' => absint(wpaam_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('wpaam_has_profile_fields_query', wp_parse_args($args, $defaults));
    $wpaam_profile_fields = new wpaam_Fields_Data_Template($args);
    return apply_filters('wpaam_has_profile_fields', $wpaam_profile_fields->has_groups(), $wpaam_profile_fields);
}