Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to change the default order of the dropdown options for the ‘post in’ choices when making an act


  • bruce-s
    Participant

    @3ruce

    Is it possible to change the default order of the dropdown options for the ‘post in’ choices from the default ‘activity’ page?

    I’d like groups that people are a member of to be shown ahead of the ‘Post in My Profile’ default.

    I’m guessing that this is handled in buddypress/bp-activity/bp-activity-actions.php, lines 204 – 281 but I’m not 100% sure if this is the case, or how to go about changing this option…

    I’d be really grateful if anyone has any thoughts or can help out at all.

    On the site, everyone is a member of a group by default and folks are advised to put posts into groups but often people end up putting the post into their profile, as opposed to the group, so getting this sorted would be great…

    Thanks everyone for such a great product and have a great weekend…

Viewing 4 replies - 1 through 4 (of 4 total)

  • Roger Coathup
    Participant

    @rogercoathup

    No, that’s not the right place to look. The drop down is set up in a front end theme file: post-form.php in the activity folder of the bp-default theme.

    In your child and / or bespoke theme, add a post-form.php file modified as you need to reorder the drop down.


    bruce-s
    Participant

    @3ruce

    Perfect – all sorted – thank you!!! (I guess I’ll have to test it a bit more for folks with more than one group though…

    Have a good weekend…


    bruce-s
    Participant

    @3ruce

    Another point I just realised, it will now default to the custom group someone is a member of, rather than ‘my profile’. It sorts multiple groups by their ID, the highest ID is the one that get’s selected…

    This is the code I’ve got from lines 33 – 71 in post-form.php in the theme (BuddyPress Corporate)

    `

    <input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="" />
    :

    <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100&populate_extras=0' ) ) :
    while ( bp_groups() ) : bp_the_group(); ?>
    <option selected="selected" value="">
    <?php endwhile;
    endif; ?>

    <input type="hidden" id="whats-new-post-in" name="whats-new-post-in" value="" />

    `


    Artform
    Participant

    @a3sthetix

    The key here is this line of PHP:

    `<?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100&populate_extras=0' ) ) :
    while ( bp_groups() ) : bp_the_group(); ?>`

    Ideally you would want to not output the group right away. You would want the group information to go into a variable for processing. The proper way to do this is with a new plugin or template file.

    So grab all the group names `bp_group_name()` and ids `bp_group_id()` into a PHP array and then run a new loop once you’ve resorted the array.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to change the default order of the dropdown options for the ‘post in’ choices when making an act’ is closed to new replies.
Skip to toolbar