This topic has 7 replies, 2 voices, and was last updated 12 years by JohnDoe.

  • Author
  • #5645
     JohnDoe
    Participant

    i was wondering if this would work, to paste the following code in bp-custom.php


    function bp_add_custom_city_list() {

    if ( !xprofile_get_field_id_from_name('City') && 'bp-profile-setup' == $_GET['page'] ) {

    $city_list_args = array(
    'field_group_id' => 1,
    'name' => 'City',
    'description' => 'Please select your city',
    'can_delete' => false,
    'field_order' => 1,
    'is_required' => false,
    'type' => 'selectbox',
    'order_by' => 'default'

    );

    $city_list_id = xprofile_insert_field( $city_list_args );

    if ( $city_list_id ) {

    $cities = array(
    "city",
    "city",

    foreach ( $cities as $i => $city ) {
    xprofile_insert_field( array(
    'field_group_id' => 1,
    'parent_id' => $city_list_id,
    'type' => 'selectbox',
    'name' => $city,
    'option_order' => $i+1
    ));
    }
    }
    }

    }
    add_action('bp_init', 'bp_add_custom_city_list');

    #5648
     JohnDoe
    Participant

    I meant in bp-functions.php

    #5650
     JohnDoe
    Participant

    Updated Code to :


    //Custom City list
    function bp_add_custom_city_list() {

    if ( !xprofile_get_field_id_from_name($bp_fields['city']) && 'bp-profile-setup' == $_GET['page'] ) {

    $city_list_args = array(
    'field_group_id' => 1,
    'name' => $bp_fields['city'],
    'description' => 'Please select your city',
    'can_delete' => false,
    'field_order' => 6,
    'is_required' => true,
    'type' => 'selectbox',
    'order_by' => 'default'

    );

    $city_list_id = xprofile_insert_field( $city_list_args );

    if ( $city_list_id ) {

    $cities = array(
    "city",
    "city",
    );

    foreach ( $cities as $i => $city ) {
    xprofile_insert_field( array(
    'field_group_id' => 1,
    'parent_id' => $city_list_id,
    'type' => 'selectbox',
    'name' => $city,
    'option_order' => $i+1
    ));
    }
    }
    }

    }
    add_action('bp_init', 'bp_add_custom_city_list');

    #5651
     JohnDoe
    Participant

    @adam what do you think about this?

    #5682
     SQadmin
    Keymaster

    See how we did it for the countries in wp-content/themes/sweetdate/custom_buddypress/bp-functions.php lines: 290 – 518

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5688
     JohnDoe
    Participant

    Instead of that, u think i could integrate an auto completer like this?


    <meta charset="utf-8">
    <style>
    .ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
    #city { width: 25em; }
    </style>
    <script>
    $(function() {
    function log( message ) {
    $( "<div/>" ).text( message ).prependTo( "#log" );
    $( "#log" ).attr( "scrollTop", 0 );
    }

    $( "#city" ).autocomplete({
    source: function( request, response ) {
    $.ajax({
    url: "http://ws.geonames.org/searchJSON",
    dataType: "jsonp",
    data: {
    featureClass: "P",
    style: "full",
    maxRows: 12,
    name_startsWith: request.term
    },
    success: function( data ) {
    response( $.map( data.geonames, function( item ) {
    return {
    label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
    value: item.name
    }
    }));
    }
    });
    },
    minLength: 2,
    select: function( event, ui ) {
    log( ui.item ?
    "Selected: " + ui.item.label :
    "Nothing selected, input was " + this.value);
    },
    open: function() {
    $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
    },
    close: function() {
    $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
    }
    });
    });
    </script>

    <div class="demo">

    <div class="ui-widget">
    <label for="city">Your city: </label>
    <input id="city" />
    Powered by geonames.org
    </div>

    <div class="ui-widget" style="margin-top:2em; font-family:Arial">
    Result:
    <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
    </div>

    </div><!-- End demo -->

    <div class="demo-description">
    <p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are cities, displayed when at least two characters are entered into the field.</p>
    <p>In this case, the datasource is the geonames.org webservice. While only the city name itself ends up in the input after selecting an element, more info is displayed in the suggestions to help find the right entry. That data is also available in callbacks, as illustrated by the Result area below the input.</p>
    </div><!-- End demo-description -->

    Looks like this : http://jqueryui.com/autocomplete/#remote-jsonp

    could you help me custom code this? willing to pay for this.

    #5748
     SQadmin
    Keymaster

    We will have something like that in next update.. so maybe is best to wait for it 😉
    it will be released this month

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5751
     JohnDoe
    Participant

    very great 😀 Robert, it keeps getting better and better. ^^

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?