bp_member_type_permissions_metabox( WP_Post $post )
Generate Profile Type Permissions Meta box.
Description
Parameters
- $post
-
(Required)
Source
File: bp-core/admin/bp-core-admin-functions.php
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 | function bp_member_type_permissions_metabox( $post ) { $meta = get_post_custom( $post ->ID ); ?><?php $enable_filter = isset( $meta [ '_bp_member_type_enable_filter' ] ) ? $meta [ '_bp_member_type_enable_filter' ][0] : 0; //disabled by default ?> <table class = "widefat bp-postbox-table" > <thead> <tr> <th scope= "col" colspan= "2" > <?php _e( 'Members Directory' , 'buddyboss' ); ?> </th> </tr> </thead> <tbody> <tr> <td colspan= "2" > <input type= 'checkbox' name= 'bp-member-type[enable_filter]' value= '1' <?php checked( $enable_filter , 1 ); ?> /> <?php _e( 'Display this profile type in "Types" filter in Members Directory' , 'buddyboss' ); ?> </td> </tr> <tr> <td colspan= "2" > <?php $enable_remove = isset( $meta [ '_bp_member_type_enable_remove' ] ) ? $meta [ '_bp_member_type_enable_remove' ][0] : 0; //enabled by default ?> <input type= 'checkbox' name= 'bp-member-type[enable_remove]' value= '1' <?php checked( $enable_remove , 1 ); ?> /> <?php _e( 'Hide all members of this type from Members Directory' , 'buddyboss' ); ?> </td> </tr> </tbody> </table> <?php if ( bp_is_active( 'groups' ) && false === bp_restrict_group_creation() ) { $get_all_registered_group_types = bp_get_active_group_types(); // Add meta box if group types is entered. if ( true === bp_disable_group_type_creation() && isset( $get_all_registered_group_types ) && ! empty ( $get_all_registered_group_types ) ) { // When profile types and group types are enabled, admins may restrict individual profile types from creating specified group types. ?> <table class = "widefat bp-postbox-table" > <thead> <tr> <th colspan= "2" > <?php _e( 'Group Type Creation' , 'buddyboss' ); ?> </th> </tr> </thead> <tbody> <tr> <td colspan= "2" > <?php _e( 'Select which group types this profile type is allowed to create. (Leave all unchecked to allow creation of any group type.)' , 'buddyboss' ); ?> </td> </tr> <?php $get_all_registered_group_types = bp_get_active_group_types(); $get_selected_group_types = get_post_meta( $post ->ID, '_bp_member_type_enabled_group_type_create' , true ) ?: []; ?> <tr> <td colspan= "2" > <input class = "group-type-checkboxes" type= 'checkbox' name= 'bp-group-type[]' value= '<?php echo esc_attr( ' none ' ); ?>' <?php checked( in_array( 'none' , $get_selected_group_types ) ); ?> /> <?php _e( '(None)' , 'buddyboss' ); ?> </td> </tr> <?php foreach ( $get_all_registered_group_types as $group_type_id ) { $group_type_key = get_post_meta( $group_type_id , '_bp_group_type_key' , true ); $group_type_label = bp_groups_get_group_type_object( $group_type_key )->labels[ 'name' ]; ?> <tr> <td colspan= "2" > <input class = "group-type-checkboxes" type= 'checkbox' name= 'bp-group-type[]' value= '<?php echo esc_attr( $group_type_key ); ?>' <?php checked( in_array( $group_type_key , $get_selected_group_types ) ); ?> /> <?php echo $group_type_label ; ?> </td> </tr> <?php } ?> </tbody> </table> <script> jQuery(document).ready( function () { jQuery( '#bp-member-type-permissions .inside .group-type-checkboxes' ).click( function () { var checkValues = jQuery(this).val(); if ( 'none' === checkValues && jQuery(this).is( ':checked' )) { jQuery( '#bp-member-type-permissions .inside .group-type-checkboxes' ).attr( 'checked' , false); jQuery( '#bp-member-type-permissions .inside .group-type-checkboxes' ).attr( 'disabled' , true); jQuery(this).attr( 'checked' , true); jQuery(this).attr( 'disabled' , false); } else { jQuery( '#bp-member-type-permissions .inside .group-type-checkboxes' ).attr( 'disabled' , false); } }); jQuery( "#bp-member-type-permissions .inside .group-type-checkboxes" ).each( function () { var checkValues = jQuery(this).val(); if ( 'none' === checkValues && jQuery(this).is( ':checked' )) { jQuery( '#bp-member-type-permissions .inside .group-type-checkboxes' ).attr( 'checked' , false); jQuery( '#bp-member-type-permissions .inside .group-type-checkboxes' ).attr( 'disabled' , true); jQuery(this).attr( 'checked' , true); jQuery(this).attr( 'disabled' , false); return false; } else { jQuery( '#bp-member-type-permissions .inside .group-type-checkboxes' ).attr( 'disabled' , false); } }); }); </script> <?php } } if ( bp_is_active( 'groups' ) && true === bp_disable_group_type_creation() && true === bp_enable_group_auto_join() && bp_is_active( 'invites' ) ) { $get_all_registered_group_types = bp_get_active_group_types(); // Add meta box if group types is entered. if ( true === bp_disable_group_type_creation() && isset( $get_all_registered_group_types ) && ! empty ( $get_all_registered_group_types ) ) { ?> <table class = "widefat bp-postbox-table" > <thead> <tr> <th colspan= "2" > <?php _e( 'Group Type Membership Approval' , 'buddyboss' ); ?> </th> </tr> </thead> <tbody> <tr> <td colspan= "2" > <?php _e( 'Selected group types will automatically approve all membership requests from users of this profile type:' , 'buddyboss' ); ?> </td> </tr> <?php $get_all_registered_group_types = bp_get_active_group_types(); $get_selected_group_types = get_post_meta( $post ->ID, '_bp_member_type_enabled_group_type_auto_join' , true )?: []; foreach ( $get_all_registered_group_types as $group_type_id ) { $group_type_key = get_post_meta( $group_type_id , '_bp_group_type_key' , true ); $group_type_label = bp_groups_get_group_type_object( $group_type_key )->labels[ 'name' ]; ?> <tr> <td colspan= "2" > <input type= 'checkbox' name= 'bp-group-type-auto-join[]' value= '<?php echo esc_attr( $group_type_key ); ?>' <?php checked( in_array( $group_type_key , $get_selected_group_types ) ); ?> /> <?php echo $group_type_label ; ?> </td> </tr> <?php } ?> </tbody> </table> <?php } } // Metabox for the profile type invite. if ( true === bp_disable_invite_member_type() && bp_is_active( 'invites' ) ) { //Allow a specific profile type to send invitations to new members and specify their profile type upon registration. $enable_invite = isset( $meta [ '_bp_member_type_enable_invite' ] ) ? $meta [ '_bp_member_type_enable_invite' ][ 0 ] : 1; //enabled by default ?> <table class = "widefat bp-postbox-table" > <thead> <tr> <th colspan= "2" > <?php _e( 'Email Invites' , 'buddyboss' ); ?> </th> </tr> </thead> <tbody> <tr> <td colspan= "2" > <input type= 'checkbox' name= 'bp-member-type-enabled-invite' value= '1' <?php checked( $enable_invite , 1 ); ?> /> <?php _e( 'Allow members to select the profile type that the invited recipient will be automatically assigned to on registration. If checked, select which of the below profile types can be assigned to the recipient:' , 'buddyboss' ); ?> </td> </tr> <?php $get_all_registered_profile_types = bp_get_active_member_types(); $get_selected_profile_types = get_post_meta( $post ->ID, '_bp_member_type_allowed_member_type_invite' , true )?: []; foreach ( $get_all_registered_profile_types as $member_type_id ) { $member_type_name = get_post_meta( $member_type_id , '_bp_member_type_label_name' , true ); ?> <tr> <td colspan= "2" > <input type= 'checkbox' name= 'bp-member-type-invite[]' value= '<?php echo esc_attr( $member_type_id ); ?>' <?php checked( in_array( $member_type_id , $get_selected_profile_types ) ); ?> /> <?php echo $member_type_name ; ?> </td> </tr> <?php } ?> </tbody> </table> <?php } } |
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
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.