Forum Replies Created

Viewing 15 replies - 301 through 315 (of 718 total)
  • Plugin Author donmik

    (@atallos)

    You can use “xprofile_get_field_data” where you need it.

    Plugin Author donmik

    (@atallos)

    Try to activate WP_DEBUG to see if there is any error.

    Also do a var_dump($value); to see what $value is.

    Plugin Author donmik

    (@atallos)

    It depends on how your website is coded. I can’t say what css you need without seeing the page.

    Plugin Author donmik

    (@atallos)

    What css?

    Plugin Author donmik

    (@atallos)

    But what you need is to change the way the date is displayed when viewing profile info or do you need to change the way the dropdown boxes are displayed in profile form and registration form?

    To do the first thing, you only have to modify the settings of date and hour in general settings in wordpress admin.

    If you want to change the way the form looks like, you will need to modify my plugin code. Search this function “bxcft_edit_render_new_xprofile_field”. The following code is responsible of displaying the 3 dropdowns boxes:

    // Dropdown => Day of month.
                    $options_day = '';
                    for ($i=1; $i<32; ++$i) {
                        $options_day .= sprintf('<option value="%s"%s>%s</option>',
                                                $i,
                                                selected($day, $i, false),
                                                $i);
                    }
                    $input = sprintf('<select name="%s_day" id="%s_day"%s><option value=""%s>--</option>%s</select>',
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                            selected($day, '', false),
                                            $options_day); 
    
                    // Dropdown => Month.
                    $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
                    $months = array(
                        __( 'January', 'buddypress' ),
                        __( 'February', 'buddypress' ),
                        __( 'March', 'buddypress' ),
                        __( 'April', 'buddypress' ),
                        __( 'May', 'buddypress' ),
                        __( 'June', 'buddypress' ),
                        __( 'July', 'buddypress' ),
                        __( 'August', 'buddypress' ),
                        __( 'September', 'buddypress' ),
                        __( 'October', 'buddypress' ),
                        __( 'November', 'buddypress' ),
                        __( 'December', 'buddypress' )
                    );
                    $options_month = '';
                    for ($i=0; $i<12; ++$i) {
                        $options_month .= sprintf('<option value="%s"%s>%s</option>',
                                                $eng_months[$i],
                                                selected( $month, $eng_months[$i], false ),
                                                $months[$i]);
                    }
                    $input .= sprintf('<select name="%s_month" id="%s_month"%s><option value=""%s>------</option>%s</select>',
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                            selected($month, '', false),
                                            $options_month);
    
                    // Dropdown => Year.
                    $birthdate_start_year = date('Y')-1;
                    $options_year = '';
                    for ($i=$birthdate_start_year; $i>1901; $i--) {
                        $options_year .= sprintf('<option value="%s"%s>%s</option>',
                                                $i,
                                                selected($year, $i, false),
                                                $i);
                    }
                    $input .= sprintf('<select name="%s_year" id="%s_year"%s><option value=""%s>----</option>%s</select>',
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_is_required()?'aria-required="true" required="required"':'',
                                            selected($year, '', false),
                                            $options_year);

    You only need to reorder like this and change two things:

    // Dropdown => Year.
                    $birthdate_start_year = date('Y')-1;
                    $options_year = '';
                    for ($i=$birthdate_start_year; $i>1901; $i--) {
                        $options_year .= sprintf('<option value="%s"%s>%s</option>',
                                                $i,
                                                selected($year, $i, false),
                                                $i);
                    }
                    $input = sprintf('<select name="%s_year" id="%s_year"%s><option value=""%s>----</option>%s</select>',
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_is_required()?'aria-required="true" required="required"':'',
                                            selected($year, '', false),
                                            $options_year);
    
                    // Dropdown => Month.
                    $eng_months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
                    $months = array(
                        __( 'January', 'buddypress' ),
                        __( 'February', 'buddypress' ),
                        __( 'March', 'buddypress' ),
                        __( 'April', 'buddypress' ),
                        __( 'May', 'buddypress' ),
                        __( 'June', 'buddypress' ),
                        __( 'July', 'buddypress' ),
                        __( 'August', 'buddypress' ),
                        __( 'September', 'buddypress' ),
                        __( 'October', 'buddypress' ),
                        __( 'November', 'buddypress' ),
                        __( 'December', 'buddypress' )
                    );
                    $options_month = '';
                    for ($i=0; $i<12; ++$i) {
                        $options_month .= sprintf('<option value="%s"%s>%s</option>',
                                                $eng_months[$i],
                                                selected( $month, $eng_months[$i], false ),
                                                $months[$i]);
                    }
                    $input .= sprintf('<select name="%s_month" id="%s_month"%s><option value=""%s>------</option>%s</select>',
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                            selected($month, '', false),
                                            $options_month);
    
                    // Dropdown => Day of month.
                    $options_day = '';
                    for ($i=1; $i<32; ++$i) {
                        $options_day .= sprintf('<option value="%s"%s>%s</option>',
                                                $i,
                                                selected($day, $i, false),
                                                $i);
                    }
                    $input .= sprintf('<select name="%s_day" id="%s_day"%s><option value=""%s>--</option>%s</select>',
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_input_name(),
                                            bp_get_the_profile_field_is_required()?'aria-required="true"':'',
                                            selected($day, '', false),
                                            $options_day);

    The first thing is the first “$input .=” of year box. The “.=” is saying concatenate this string to $input. Now, the year box is the first so we do not need to concatenate. We need to change:
    $input .=
    With:
    $input =

    The second thing is before, the first “$input =” was day of month, now it’s the last box, so you need to concatenate to the previous $input. For day of month, we need to change:
    $input =
    With:
    $input .=

    This is probably why you see only one box…

    Plugin Author donmik

    (@atallos)

    I don’t understand. What field type are you using (datepicker, birthdate, …)? Give me some screenshots or url to see this? Can you explain a bit more please?

    Plugin Author donmik

    (@atallos)

    Hi,

    This field type is not from my plugin, it’s from xprofile extension of buddypress… To do this, you need to use css, all you want to do is possible with css.

    Plugin Author donmik

    (@atallos)

    Hi,

    I believe “Only me” is now the same thing as “Nobody”… so if you are using the latest version of buddypress, there are the same visibility… I should remove it in future updates.

    Plugin Author donmik

    (@atallos)

    You’re welcome ;=)

    Plugin Author donmik

    (@atallos)

    // For each description we have.
        jQuery('p.description').each(function() {
            // Clone description.
            // Looking for parent div.
            // Looking for label of checkbox field or radio field first.
            var desc = jQuery(this).clone(),
                parent = jQuery(this).parent(),
                label = parent.find('span.label');
            // If there is no label of checkbox field or radio field, we look for normal labels.
            if (!label.length) {
                label = parent.find('label:first');
            }
            // If there is a label.
            if (label.length) {
                // Putting the description after the label.
                label.after(desc);
                // Removing the original description.
                jQuery(this).remove();
            }
            jQuery('.checkbox-acceptance > p.description').remove();
        });

    Not the best way, but it’s the faster…xD. Try it…

    Plugin Author donmik

    (@atallos)

    I can’t see the checkbox acceptance? Where is it?

    Plugin Author donmik

    (@atallos)

    Sorry, I was not aware the theme you are using has a different html than buddypress default theme. This is why my code doesn’t work…

    Try this instead:

    // For each description we have.
        jQuery('p.description').each(function() {
            // Clone description.
            // Looking for parent div.
            // Looking for label of checkbox field or radio field first.
            var desc = jQuery(this).clone(),
                parent = jQuery(this).parent(),
                label = parent.find('span.label');
            // If there is no label of checkbox field or radio field, we look for normal labels.
            if (!label.length) {
                label = parent.find('label:first');
            }
            // If there is a label.
            if (label.length) {
                // Putting the description after the label.
                label.after(desc);
                // Removing the original description.
                jQuery(this).remove();
            }
        });

    Plugin Author donmik

    (@atallos)

    If you update to 1.5.9.4, this warning should disappear.

    Plugin Author donmik

    (@atallos)

    Hi,

    The filter seems all right. Check if the if you are using is working. Something like this:

    add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4);
    function my_show_field($value_to_return, $type, $id, $value) {
        if ($type == 'number') {
            $value = str_replace("<p>", "", $value);
            $value = str_replace("</p>", "", $value);
            $field = new BP_XProfile_Field($id);
            if ($field->name == 'Waarde van je gadget (€)') {
                echo "WE ARE HERE!!!";
    		     setlocale(LC_MONETARY, 'nl_NL');
                $value = money_format('%.2n', $value) . "\n";
                $new_value = money_format('%.2n', $value) . "\n";
            } else {
                $new_value = $value;
            }
            return '<p>'.$new_value.'</p>';
        }
        return $value_to_return;
    }

    If you are not seeing the string “WE ARE HERE!!!”, the error is in the if sentence. So check what is inside $field->name and compare with your string.

    Plugin Author donmik

    (@atallos)

    Right, I haven’t tested with radios or checkboxes. Use this code:

    // For each description we have.
    jQuery('p.description').each(function() {
        // Clone description.
        // Looking for parent div.
        // Looking for label of checkbox field or radio field first.
        var desc = jQuery(this).clone(),
            parent = jQuery(this).parent(),
            label = parent.find('span.label');
        // The div we're looking for has "editfield" class, if not, this is not the field.
        if (!parent.hasClass('editfield')) {
            parent = parent.parent();
        }
        // If there is no label of checkbox field or radio field, we look for normal labels.
        if (!label.length) {
            label = parent.find('label');
        }
        // If there is a label.
        if (label.length) {
            // Putting the description after the label.
            label.after(desc);
            // Removing the original description.
            jQuery(this).remove();
        }
    });

    Check if this works please and I will add to the FAQ.

Viewing 15 replies - 301 through 315 (of 718 total)