• Resolved Andres Felipe

    (@naturalworldstm)


    Hi and thanks for this excellent plugin. I’m using it a few hours ago and have some doubts:

    1. Is it possible to link the Website field to a blank new page? Currently is leaving the people outside my site when clicking on some website field.
    2. After activate it, the privacy options for the fields added for the plugin appearse over the field name in front-end. The privacy remains working for that field but appears over the field name and below last field privacy option. Any idea?
    3. For birthday field I’m trying to show only day and month, not year. I’m following a current topic with another user and have the same problem, it’s showing the current day.
    4. In order to keep the things ok until at least the privacy option issue be solved, can I deactivate the plugin without lose the fields associated with this plugin?
    5. Is it possible in “custom post” field to make it clickable? I want people choose one of this and when save it, people who can see it can click on it and go to that custom post page.

    Thanks for your time and sorry for my english!

    https://www.ads-software.com/extend/plugins/buddypress-xprofile-custom-fields-type/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author donmik

    (@atallos)

    Hi,

    I have just updated my plugin to add a new filter. Now you can use this filter to change the way it shows the field value. The filter name is bxcft_show_field_value. So to customize, birthdate, website or custom post type do it adding this filter in your functions.php:

    add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4);
    function my_show_field($value, $type, $id, $value_to_return) {
    if ($type == 'birthdate') {
            $value = str_replace("<p>", "", $value);
            $value = str_replace("</p>", "", $value);
            $field = new BP_XProfile_Field($id);
            // Get children.
            $childs = $field->get_children();
            $show_age = false;
            if (isset($childs) && $childs && count($childs) > 0) {
                // Get the name of custom post type.
                if ($childs[0]->name == 'show_age')
                    $show_age = true;
            }
            if ($show_age) {
                return '<p>'.floor((time() - strtotime($value))/31556926).'</p>';
            }
            return '<p>'.date_i18n( 'F j' , strtotime($value) ).'</p>';
        } elseif ($type == 'web') {
            if (strpos($value, 'href=') === false) {
                $value = str_replace("<p>", "", $value);
                $value = str_replace("</p>", "", $value);
                return '<p><a href="'.$value.'" target="_blank">'.$value.'</a></p>';
            } else {
                $value = str_replace('href=', 'target="_blank" href=', $value);
                return $value;
            }
        } elseif ($type == 'select_custom_post_type') {
            $value = str_replace("<p>", "", $value);
            $value = str_replace("</p>", "", $value);
            // Get children.
            $field = new BP_XProfile_Field($id);
            $childs = $field->get_children();
            if (isset($childs) && count($childs) > 0) {
                // Get the name of custom post type.
                $custom_post_type = $childs[0]->name;
            }
            $post = get_post($value);
            if ($post->post_type == $custom_post_type) {
                return '<p><a href="'.  get_permalink($post->ID).'">'.$post->post_title.'</a></p>';
            } else {
                // Custom post type is not the same.
                return '<p>--</p>';
            }
        }
    
        return $value_to_return;
    }

    The first if is the same if for birthdate, it must show the birthdate without year. If it does not work, try to var_dump($value); and we will see what value is contained. If it is empty there is a problem when saving birthdate.

    The second if is for website. I’ve added a target=”_blank”.

    The third id is for custom post type. I’ve added a link to permalink of post.

    All this code answer to 1, 3 and 5.

    2. Can I see a picture of what are you saying about privacy options or maybe you can send me a link to see for myself.

    4. No, you cannot deactivate plugin, the fields won’t disappear but the users can still see them when they edit their profile and while this plugin is deactivated, they will show the fields as textboxes. So you can have some errors.

    No problem!

    Thread Starter Andres Felipe

    (@naturalworldstm)

    1,3,5. Are You serious??? You’re awesome!!! that code works like a charm!!!

    2. You can see it here with demo, demo. This is a capture.

    4. Nevermind, now I don’t want to deactivate the plugin. Is excellent!!!

    atallos, thanks for all your time and hard work!!!

    P.S.: Where can I send You a correction for the es_ES file? actually is just one word than remains in English “Nobody” to “Solo yo” or “Nadie”, I think is better “Solo yo”.

    Plugin Author donmik

    (@atallos)

    For the privacy options, you were right. I thought I solved this in one of the latest updates but I was wrong. Now I think it will work. The only problem is what i was saying in other thread, the description of the field will still appear after the privacy options, you need to change this manually in your templates. I cannot do anything in my plugin to change the position of the description of field.

    I’ve added what you say about the spanish translation. Thanks for your advice!

    Plugin Author donmik

    (@atallos)

    I’ve uploaded a new version 1.5.5.1 and the code I’ve posted here will not work, you only need to change this:

    function my_show_field($value, $type, $id, $value_to_return) {

    with this:

    function my_show_field($value_to_return, $type, $id, $value) {

    You only need to swap the position of $value_to_return and $value and it should work. If not, get in touch and I take a look.

    Thread Starter Andres Felipe

    (@naturalworldstm)

    Hi atallos

    After update and changing this line, everything is ok.

    For the privacy options the problem remains, I tried to make the change You suggested in another topic and when I changed that line, the privacy option place is ok but if I want to change from say friends to anyone, when I click in change, the whole field dissapear.

    For the record I’m still in BP 1.6.x, I’ll update BP later today and check again if the privacy option has been changed.

    Thread Starter Andres Felipe

    (@naturalworldstm)

    If someone is reading this, with 1.5.5.3 everything is working excellent with 1.6.x or 1.7!!!

    Thanks a lot atallos!!!

    Thread Starter Andres Felipe

    (@naturalworldstm)

    Hi Atallos

    Since I don’t know wich update, the position of privacy option is again in the wrong place. This is a capture how it looks now https://dl.dropboxusercontent.com/u/60768679/privacy.jpg

    In 1.5.5.3 it was ok with this code:

    add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4);
    function my_show_field($value_to_return, $type, $id, $value) {
    if ($type == 'birthdate') {
            $value = str_replace("<p>", "", $value);
            $value = str_replace("</p>", "", $value);
            $field = new BP_XProfile_Field($id);
            // Get children.
            $childs = $field->get_children();
            $show_age = false;
            if (isset($childs) && $childs && count($childs) > 0) {
                // Get the name of custom post type.
                if ($childs[0]->name == 'show_age')
                    $show_age = true;
            }
            if ($show_age) {
                return '<p>'.floor((time() - strtotime($value))/31556926).'</p>';
            }
            return '<p>'.date_i18n( 'F j' , strtotime($value) ).'</p>';
        } elseif ($type == 'web') {
            if (strpos($value, 'href=') === false) {
                $value = str_replace("<p>", "", $value);
                $value = str_replace("</p>", "", $value);
                return '<p><a href="'.$value.'" target="_blank">'.$value.'</a></p>';
            } else {
                $value = str_replace('href=', 'target="_blank" href=', $value);
                return $value;
            }
        } elseif ($type == 'select_custom_post_type') {
            $value = str_replace("<p>", "", $value);
            $value = str_replace("</p>", "", $value);
            // Get children.
            $field = new BP_XProfile_Field($id);
            $childs = $field->get_children();
            if (isset($childs) && count($childs) > 0) {
                // Get the name of custom post type.
                $custom_post_type = $childs[0]->name;
            }
            $post = get_post($value);
            if ($post->post_type == $custom_post_type) {
                return '<p><a href="'.  get_permalink($post->ID).'">'.$post->post_title.'</a></p>';
            } else {
                // Custom post type is not the same.
                return '<p>--</p>';
            }
        }
    
        return $value_to_return;
    }

    Do I need to change something in functions?

    Thanks in advance!

    Plugin Author donmik

    (@atallos)

    Hi,

    I don’t change anything about this, I think. Check in your edit.php (bp-themes/bp-default/members/single/profile/edit.php) where is the hook. If you are using buddypress 1.7:

    do_action( 'bp_custom_profile_edit_fields_pre_visibility' );

    Must be before visibility settings.

    If you are using prior versions of buddypress, you will see this hook:
    do_action('bp_custom_profile_edit_fields');
    It must be after visibility settings. You can change where it shows, changing the position of this hook, writing before visibility settings.

    Thread Starter Andres Felipe

    (@naturalworldstm)

    Hi atallos and sorry for the loooooooooong delay

    It still is in the wrong place as You can see in this capture

    Do You have any idea?

    Thanks for your time!

    Plugin Author donmik

    (@atallos)

    Hi,

    Sorry but I have no idea. Check your theme files and look for the hooks or see if the hook is placed above the code of visibility. You need to check your theme files with buddypress default theme because it works great with buddypress default theme.

    Thread Starter Andres Felipe

    (@naturalworldstm)

    You are right, I don’t know why but in 1.6.x doesn’t work but with 1.7.x works with the same theme.

    Thanks for your support!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Some issues’ is closed to new replies.