BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 6
    Vlad on #39770

    Hi Brajesh,
    I noticed that the filter actions are reset when you go to the next page,
    can you help me fix this.

  • Participant
    Level: Initiated
    Posts: 6
    Vlad on #39751

    Hi Brajesh,
    i didn’t work with pastebin,
    here is the code working,
    the page is reloading,
    works faster than ajax,
    will you advise how to do it better,
    this is how i did – https://photos.app.goo.gl/5zt7vSC4r3vkAjbZ7

    <?php
    global $wpdb, $bp;
    ?>
    <div>
    <form action=”” method=”get” name=”form_filter” id=”form_filter”>
    <select name=”groups_search_city” id=”groups_search_city” class=”livesearch”>
    <option value=””>Выбрать город</option>

    <?php

    $cities = $wpdb->get_col(“SELECT DISTINCT meta_value FROM wp_bp_groups_groupmeta WHERE meta_key = ‘group_custom_field_city'”);

    foreach ( $cities as $city ) {
    echo ‘<option value=”‘ . $city . ‘”>’ . $city . ‘</option>’;
    }
    ?>
    </select>

    <select name=”groups_search_working” id=”groups_search_working” class=”livesearch”>
    <option value=””>Выбрать вид деятельности</option>

    <?php
    $workings = $wpdb->get_col(“SELECT DISTINCT meta_value FROM wp_bp_groups_groupmeta WHERE meta_key = ‘group_custom_field_working'”);
    foreach ( $workings as $working ) {
    echo ‘<option value=”‘ . $working . ‘”>’ . $working . ‘</option>’;
    }
    ?>
    </select>
    <select name=”groups-order-by” id=”groups-order-by” class=”livesearch”>
    <option value=”active”><?php esc_html_e( ‘Last Active’, ‘buddypress’ ); ?></option>
    <option value=”popular”><?php esc_html_e( ‘Most Members’, ‘buddypress’ ); ?></option>
    <option value=”newest”><?php esc_html_e( ‘Newly Created’, ‘buddypress’ ); ?></option>
    <option value=”alphabetical”><?php esc_html_e( ‘Alphabetical’, ‘buddypress’ ); ?></option>
    </select>
    <?php
    $args_meta = array(
    ‘type’ => $_POST[‘groups-order-by’],
    ‘per_page’ => ’12’,
    ‘meta_query’ => array(
    ‘relation’ => ‘AND’,
    ‘group_custom_field_city’ => array(
    ‘key’ => ‘group_custom_field_city’,
    ‘value’ => $_POST[‘groups_search_city’],
    ‘compare’ => ‘LIKE’,
    ),

    ‘group_custom_field_working’ => array(
    ‘key’ => ‘group_custom_field_working’,
    ‘value’ => $_POST[‘groups_search_working’],
    ‘compare’ => ‘LIKE’,
    ),
    ),

    ‘orderby’ => array(
    ‘group_custom_field_city’ => ‘ASC’,
    ‘group_custom_field_working’ => ‘ASC’,
    )
    );
    ?>
    <input type=”submit” value=”search” /> reset
    </form>
    </div>

    <?php if ( bp_has_groups( $args_meta )) : ?>

  • Participant
    Level: Initiated
    Posts: 6
    Vlad on #39721

    Hello Brajesh,
    did so,
    it is working,
    the page reloads,
    filter bp_groups_directory_order_options stopped working,
    what do you recommend on the filter


    <?php

    global $wpdb, $bp;
    ?>
    <div>
    <form action=”” method=”get”>

    <select name=”groups_search_city” id=”groups_search_city”>
    <option value=””>City</option>
    <?php

    $cities = $wpdb->get_col(“SELECT DISTINCT meta_value FROM wp_bp_groups_groupmeta WHERE meta_key = ‘group_custom_field_city'”);

    foreach ( $cities as $city ) {
    echo ‘<option value=”‘ . $city . ‘”>’ . $city . ‘</option>’;
    }
    ?>
    </select>

    <select name=”groups_search_working” id=”groups_search_working”>
    <option value=””>Working</option>

    <?php

    $workings = $wpdb->get_col(“SELECT DISTINCT meta_value FROM wp_bp_groups_groupmeta WHERE meta_key = ‘group_custom_field_working'”);

    foreach ( $workings as $working ) {
    echo ‘<option value=”‘ . $working . ‘”>’ . $working . ‘</option>’;
    }
    ?>
    </select>

    <?php

    $args_meta = array(
    ‘post-type’ => ‘groups’,
    ‘per_page’ => ’24’,

    ‘meta_query’ => array(
    ‘relation’ => ‘AND’,

    ‘group_custom_field_city’ => array(
    ‘key’ => ‘group_custom_field_city’,
    ‘value’ => $_POST[‘groups_search_city’],
    ‘compare’ => ‘LIKE’,
    ),

    ‘group_custom_field_working’ => array(
    ‘key’ => ‘group_custom_field_working’,
    ‘value’ => $_POST[‘groups_search_working’],
    ‘compare’ => ‘LIKE’,
    ),
    ),

    ‘orderby’ => array(
    ‘group_custom_field_city’ => ‘ASC’,
    ‘group_custom_field_working’ => ‘ASC’,
    )
    );

    ?>
    <input type=”submit” value=”Search” />
    </form>
    </div>

    <?php if ( bp_has_groups( $args_meta, ( bp_ajax_querystring( ‘groups’ )) . ‘&per_page=’ . svq_option( ‘bp_groups_perpage’, 24 ) ) ) : ?>

  • Participant
    Level: Initiated
    Posts: 6
    Vlad on #38251

    Thanks Brajesh,
    the code works as it should,
    you are a very good specialist
    helped me a lot.

    Items 2, 4.
    I did it with google.
    Found plugins:
    https://github.com/JonasSkjodt/buddypress-group-tabs
    https://wordpress.org/plugins/bp-devolved-authority/
    remade for myself.

    I am glad that I had a good time with you.

    Best regards, Vlad

  • Participant
    Level: Initiated
    Posts: 6
    Vlad on #38193

    Hello Brajesh,

    Sorry for my English.
    I’ll write again.

    Yes, I need a code for 1 and 3.

    1. I need to automatically create 1 field in the profile of the site members, in the specified group of fields,
    when creating a user group.
    Field name: slug of the user group.

    3. The field is removed from the profile of all site members,
    when deleting a user group.

    Thanks for the help.

  • Participant
    Level: Initiated
    Posts: 6
    Vlad on #38133

    Thanks for answering Brajesh,

    Yes, I need a code for 1 and 3.

    1. I need 1 field in the profile of the site members,
    in the specified field group.
    Field name – slug by user group.

    3. The field is removed from the profile for all site members,
    when deleting a user group.

    Write how much the work on item 2 will cost,
    and how much the work on item 4 will cost.

    Thanks for the help.