BP_REST_Group_Settings_Endpoint::get_settings_fields( integer $group_id )
Get Group Settings.
Description
Parameters
- $group_id
-
(Required) Group ID.
Return
(mixed|void)
Source
File: bp-groups/classes/class-bp-rest-group-settings-endpoint.php
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | protected function get_settings_fields( $group_id ) { $fields = array (); buddypress()->groups->current_group = groups_get_group( $group_id ); $fields [] = array ( 'label' => esc_html__( 'Privacy Options' , 'buddyboss' ), 'name' => 'group-status' , 'description' => '' , 'field' => 'radio' , 'value' => bp_get_new_group_status(), 'options' => array ( array ( 'label' => esc_html__( 'This is a public group' , 'buddyboss' ), 'value' => 'public' , 'description' => '<ul id="public-group-description">' . '<li>' . esc_html__( 'Any site member can join this group.' , 'buddyboss' ) . '</li>' . '<li>' . esc_html__( 'This group will be listed in the groups directory and in search results.' , 'buddyboss' ) . '</li>' . '<li>' . esc_html__( 'Group content and activity will be visible to any site member.' , 'buddyboss' ) . '</li>' . '</ul>' , 'is_default_option' => 'public' === bp_get_new_group_status() || ! bp_get_new_group_status(), ), array ( 'label' => esc_html__( 'This is a private group' , 'buddyboss' ), 'value' => 'private' , 'description' => '<ul id="public-group-description">' . '<li>' . esc_html__( 'Only people who request membership and are accepted can join the group.' , 'buddyboss' ) . '</li>' . '<li>' . esc_html__( 'This group will be listed in the groups directory and in search results.' , 'buddyboss' ) . '</li>' . '<li>' . esc_html__( 'Group content and activity will only be visible to members of the group.' , 'buddyboss' ) . '</li>' . '</ul>' , 'is_default_option' => 'private' === bp_get_new_group_status(), ), array ( 'label' => esc_html__( 'This is a hidden group' , 'buddyboss' ), 'value' => 'hidden' , 'description' => '<ul id="public-group-description">' . '<li>' . esc_html__( 'Only people who are invited can join the group.' , 'buddyboss' ) . '</li>' . '<li>' . esc_html__( 'This group will not be listed in the groups directory or search results' , 'buddyboss' ) . '</li>' . '<li>' . esc_html__( 'Group content and activity will only be visible to members of the group.' , 'buddyboss' ) . '</li>' . '</ul>' , 'is_default_option' => 'private' === bp_get_new_group_status(), ), ), ); $fields [] = array ( 'label' => esc_html__( 'Group Invitations' , 'buddyboss' ), 'name' => 'group-invite-status' , 'description' => esc_html__( 'Which members of this group are allowed to invite others?' , 'buddyboss' ), 'field' => 'radio' , 'value' => bp_group_get_invite_status( $group_id ), 'options' => array ( array ( 'label' => esc_html__( 'All group members' , 'buddyboss' ), 'value' => 'members' , 'description' => '' , 'is_default_option' => 'members' === bp_group_get_invite_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers and Moderators only' , 'buddyboss' ), 'value' => 'mods' , 'description' => '' , 'is_default_option' => 'mods' === bp_group_get_invite_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers only' , 'buddyboss' ), 'value' => 'admins' , 'description' => '' , 'is_default_option' => 'admins' === bp_group_get_invite_status( $group_id ), ), ), ); $fields [] = array ( 'label' => esc_html__( 'Activity Feeds' , 'buddyboss' ), 'name' => 'group-activity-feed-status' , 'description' => esc_html__( 'Which members of this group are allowed to post into the activity feed?' , 'buddyboss' ), 'field' => 'radio' , 'value' => bp_group_get_activity_feed_status( $group_id ), 'options' => array ( array ( 'label' => esc_html__( 'All group members' , 'buddyboss' ), 'value' => 'members' , 'description' => '' , 'is_default_option' => 'members' === bp_group_get_activity_feed_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers and Moderators only' , 'buddyboss' ), 'value' => 'mods' , 'description' => '' , 'is_default_option' => 'mods' === bp_group_get_activity_feed_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers only' , 'buddyboss' ), 'value' => 'admins' , 'description' => '' , 'is_default_option' => 'admins' === bp_group_get_activity_feed_status( $group_id ), ), ), ); if ( bp_is_active( 'media' ) && bp_is_group_media_support_enabled() ) { $fields [] = array ( 'label' => esc_html__( 'Group Photos' , 'buddyboss' ), 'name' => 'group-media-status' , 'description' => esc_html__( 'Which members of this group are allowed to manage photos?' , 'buddyboss' ), 'field' => 'radio' , 'value' => bp_group_get_media_status( $group_id ), 'options' => array ( array ( 'label' => esc_html__( 'All group members' , 'buddyboss' ), 'value' => 'members' , 'description' => '' , 'is_default_option' => 'members' === bp_group_get_media_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers and Moderators only' , 'buddyboss' ), 'value' => 'mods' , 'description' => '' , 'is_default_option' => 'mods' === bp_group_get_media_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers only' , 'buddyboss' ), 'value' => 'admins' , 'description' => '' , 'is_default_option' => 'admins' === bp_group_get_media_status( $group_id ), ), ), ); } if ( bp_is_active( 'media' ) && bp_is_group_media_support_enabled() ) { $fields [] = array ( 'label' => esc_html__( 'Group Albums' , 'buddyboss' ), 'name' => 'group-album-status' , 'description' => esc_html__( 'Which members of this group are allowed to manage albums?' , 'buddyboss' ), 'field' => 'radio' , 'value' => bp_group_get_album_status( $group_id ), 'options' => array ( array ( 'label' => esc_html__( 'All group members' , 'buddyboss' ), 'value' => 'members' , 'description' => '' , 'is_default_option' => 'members' === bp_group_get_album_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers and Moderators only' , 'buddyboss' ), 'value' => 'mods' , 'description' => '' , 'is_default_option' => 'mods' === bp_group_get_album_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers only' , 'buddyboss' ), 'value' => 'admins' , 'description' => '' , 'is_default_option' => 'admins' === bp_group_get_album_status( $group_id ), ), ), ); } if ( bp_is_active( 'messages' ) && function_exists( 'bp_disable_group_messages' ) && true === bp_disable_group_messages() ) { $fields [] = array ( 'label' => esc_html__( 'Group Messages' , 'buddyboss' ), 'name' => 'group-message-status' , 'description' => esc_html__( 'Which members of this group are allowed to send group messages?' , 'buddyboss' ), 'field' => 'radio' , 'value' => bp_group_get_message_status( $group_id ), 'options' => array ( array ( 'label' => esc_html__( 'All group members' , 'buddyboss' ), 'value' => 'members' , 'description' => '' , 'is_default_option' => 'members' === bp_group_get_message_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers and Moderators only' , 'buddyboss' ), 'value' => 'mods' , 'description' => '' , 'is_default_option' => 'mods' === bp_group_get_message_status( $group_id ), ), array ( 'label' => esc_html__( 'Organizers only' , 'buddyboss' ), 'value' => 'admins' , 'description' => '' , 'is_default_option' => 'admins' === bp_group_get_message_status( $group_id ), ), ), ); } // Group Types. $group_types = bp_groups_get_group_types( array ( 'show_in_create_screen' => true ), 'objects' ); // Hide Group Types if none is selected in Users > Profile Type > E.g. (Students) > Allowed Group Types meta box. if ( function_exists( 'bp_restrict_group_creation' ) && function_exists( 'bp_member_type_enable_disable' ) && false === bp_restrict_group_creation() && true === bp_member_type_enable_disable() ) { $get_all_registered_member_types = bp_get_active_member_types(); if ( isset( $get_all_registered_member_types ) && ! empty ( $get_all_registered_member_types ) ) { $current_user_member_type = bp_get_member_type( bp_loggedin_user_id() ); if ( '' !== $current_user_member_type ) { $member_type_post_id = bp_member_type_post_by_type( $current_user_member_type ); $include_group_type = get_post_meta( $member_type_post_id , '_bp_member_type_enabled_group_type_create' , true ); if ( isset( $include_group_type ) && ! empty ( $include_group_type ) && 'none' === $include_group_type [0] ) { $group_types = '' ; } } } } if ( $group_types ) { $group_type_field = array ( 'label' => esc_html__( 'Group Type' , 'buddyboss' ), 'name' => 'group-types' , 'description' => esc_html__( 'What type of group is this? (optional)' , 'buddyboss' ), 'field' => 'select' , 'value' => '' , 'options' => array (), ); $group_hierarchies [ 'options' ][] = array ( 'label' => __( 'Select Group Type' , 'buddyboss' ), 'value' => '' , 'description' => '' , 'is_default_option' => '' , ); foreach ( $group_types as $type ) { if ( function_exists( 'bp_restrict_group_creation' ) && function_exists( 'bp_member_type_enable_disable' ) && false === bp_restrict_group_creation() && true === bp_member_type_enable_disable() ) { $get_all_registered_member_types = bp_get_active_member_types(); if ( isset( $get_all_registered_member_types ) && ! empty ( $get_all_registered_member_types ) ) { $current_user_member_type = bp_get_member_type( bp_loggedin_user_id() ); if ( '' !== $current_user_member_type ) { $member_type_post_id = bp_member_type_post_by_type( $current_user_member_type ); $include_group_type = get_post_meta( $member_type_post_id , '_bp_member_type_enabled_group_type_create' , true ); if ( isset( $include_group_type ) && ! empty ( $include_group_type ) ) { if ( in_array( $type ->name, $include_group_type , true ) ) { $group_type_field [ 'options' ][] = array ( 'label' => $type ->labels[ 'singular_name' ], 'value' => $type ->name, 'description' => '' , 'is_default_option' => ( ( ( true === bp_groups_has_group_type( $group_id , $type ->name ) ) ? $type ->name : '' ) === $type ->name ), ); } } else { $group_type_field [ 'options' ][] = array ( 'label' => $type ->labels[ 'singular_name' ], 'value' => $type ->name, 'description' => '' , 'is_default_option' => ( ( ( true === bp_groups_has_group_type( $group_id , $type ->name ) ) ? $type ->name : '' ) === $type ->name ), ); } } else { $group_type_field [ 'options' ][] = array ( 'label' => $type ->labels[ 'singular_name' ], 'value' => $type ->name, 'description' => '' , 'is_default_option' => ( ( ( true === bp_groups_has_group_type( $group_id , $type ->name ) ) ? $type ->name : '' ) === $type ->name ), ); } } else { $group_type_field [ 'options' ][] = array ( 'label' => $type ->labels[ 'singular_name' ], 'value' => $type ->name, 'description' => '' , 'is_default_option' => ( ( ( true === bp_groups_has_group_type( $group_id , $type ->name ) ) ? $type ->name : '' ) === $type ->name ), ); } } else { $group_type_field [ 'options' ][] = array ( 'label' => $type ->labels[ 'singular_name' ], 'value' => $type ->name, 'description' => '' , 'is_default_option' => ( ( ( true === bp_groups_has_group_type( $group_id , $type ->name ) ) ? $type ->name : '' ) === $type ->name ), ); } } $fields [] = $group_type_field ; } // --Group Types. if ( function_exists( 'bp_enable_group_hierarchies' ) && bp_enable_group_hierarchies() ) { $current_parent_group_id = bp_get_parent_group_id(); $possible_parent_groups = bp_get_possible_parent_groups(); $group_hierarchies = array ( 'label' => esc_html__( 'Group Parent' , 'buddyboss' ), 'name' => 'bp-groups-parent' , 'description' => esc_html__( 'Which group should be the parent of this group? (optional)' , 'buddyboss' ), 'field' => 'select' , 'value' => $current_parent_group_id , 'options' => array (), ); if ( $possible_parent_groups ) { $group_hierarchies [ 'options' ][] = array ( 'label' => __( 'Select Parent' , 'buddyboss' ), 'value' => 0, 'description' => '' , 'is_default_option' => empty ( $current_parent_group_id ) || 0 === $current_parent_group_id , ); foreach ( $possible_parent_groups as $possible_parent_group ) { $group_hierarchies [ 'options' ][] = array ( 'label' => $possible_parent_group ->name, 'value' => $possible_parent_group ->id, 'description' => '' , 'is_default_option' => ( $current_parent_group_id === $possible_parent_group ->id ), ); } } $fields [] = $group_hierarchies ; } return apply_filters( 'bp_rest_group_settings' , $fields , $group_id ); } |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.