bp_groups_admin_edit()
Display the single groups edit screen.
Description
Source
File: bp-groups/bp-groups-admin.php
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 | function bp_groups_admin_edit() { if ( ! bp_current_user_can( 'bp_moderate' ) ) die ( '-1' ); $messages = array (); // If the user has just made a change to a group, build status messages. if ( ! empty ( $_REQUEST [ 'no_admins' ] ) || ! empty ( $_REQUEST [ 'error' ] ) || ! empty ( $_REQUEST [ 'updated' ] ) || ! empty ( $_REQUEST [ 'error_new' ] ) || ! empty ( $_REQUEST [ 'success_new' ] ) || ! empty ( $_REQUEST [ 'error_modified' ] ) || ! empty ( $_REQUEST [ 'success_modified' ] ) ) { $no_admins = ! empty ( $_REQUEST [ 'no_admins' ] ) ? 1 : 0; $errors = ! empty ( $_REQUEST [ 'error' ] ) ? $_REQUEST [ 'error' ] : '' ; $updated = ! empty ( $_REQUEST [ 'updated' ] ) ? $_REQUEST [ 'updated' ] : '' ; $error_new = ! empty ( $_REQUEST [ 'error_new' ] ) ? explode ( ',' , $_REQUEST [ 'error_new' ] ) : array (); $success_new = ! empty ( $_REQUEST [ 'success_new' ] ) ? explode ( ',' , $_REQUEST [ 'success_new' ] ) : array (); $error_modified = ! empty ( $_REQUEST [ 'error_modified' ] ) ? explode ( ',' , $_REQUEST [ 'error_modified' ] ) : array (); $success_modified = ! empty ( $_REQUEST [ 'success_modified' ] ) ? explode ( ',' , $_REQUEST [ 'success_modified' ] ) : array (); if ( ! empty ( $no_admins ) ) { $messages [] = __( 'This group must have at least one organizer.' , 'buddyboss' ); } if ( ! empty ( $errors ) ) { if ( $errors < 0 ) { $messages [] = __( 'Group name, slug, and description are all required fields.' , 'buddyboss' ); } else { $messages [] = __( 'An error occurred when trying to update your group details.' , 'buddyboss' ); } } elseif ( ! empty ( $updated ) ) { $messages [] = __( 'The group has been updated successfully.' , 'buddyboss' ); } if ( ! empty ( $error_new ) ) { $messages [] = sprintf( __( 'The following users could not be added to the group: %s' , 'buddyboss' ), '<em>' . esc_html( implode( ', ' , $error_new ) ) . '</em>' ); } if ( ! empty ( $success_new ) ) { $messages [] = sprintf( __( 'The following users were successfully added to the group: %s' , 'buddyboss' ), '<em>' . esc_html( implode( ', ' , $success_new ) ) . '</em>' ); } if ( ! empty ( $error_modified ) ) { $error_modified = bp_groups_admin_get_usernames_from_ids( $error_modified ); $messages [] = sprintf( __( 'An error occurred when trying to modify the following members: %s' , 'buddyboss' ), '<em>' . esc_html( implode( ', ' , $error_modified ) ) . '</em>' ); } if ( ! empty ( $success_modified ) ) { $success_modified = bp_groups_admin_get_usernames_from_ids( $success_modified ); $messages [] = sprintf( __( 'The following members were successfully modified: %s' , 'buddyboss' ), '<em>' . esc_html( implode( ', ' , $success_modified ) ) . '</em>' ); } } $is_error = ! empty ( $no_admins ) || ! empty ( $errors ) || ! empty ( $error_new ) || ! empty ( $error_modified ); // Get the group from the database. $group = groups_get_group( (int) $_GET [ 'gid' ] ); $group_name = isset( $group ->name ) ? bp_get_group_name( $group ) : '' ; // Construct URL for form. $form_url = remove_query_arg( array ( 'action' , 'deleted' , 'no_admins' , 'error' , 'error_new' , 'success_new' , 'error_modified' , 'success_modified' ), $_SERVER [ 'REQUEST_URI' ] ); $form_url = add_query_arg( 'action' , 'save' , $form_url ); /** * Fires before the display of the edit form. * * Useful for plugins to modify the group before display. * * @since BuddyPress 1.7.0 * * @param BP_Groups_Group $this Instance of the current group being edited. Passed by reference. */ do_action_ref_array( 'bp_groups_admin_edit' , array ( & $group ) ); ?> <div class = "wrap" > <?php if ( version_compare( $GLOBALS [ 'wp_version' ], '4.8' , '>=' ) ) : ?> <h1 class = "wp-heading-inline" ><?php _e( 'Edit Group' , 'buddyboss' ); ?></h1> <?php if ( is_user_logged_in() && bp_user_can_create_groups() ) : ?> <a class = "page-title-action" href= "<?php echo esc_url( add_query_arg([ 'page' => 'bp-groups', 'create' => 'create-from-admin', 'action' => 'edit', ], admin_url( 'admin.php' ) ) ); ?>" ><?php _e( 'New Group' , 'buddyboss' ); ?></a> <?php endif ; ?> <hr class = "wp-header-end" > <?php else : ?> <h1><?php _e( 'Edit Group' , 'buddyboss' ); ?> <?php if ( is_user_logged_in() && bp_user_can_create_groups() ) : ?> <a class = "add-new-h2" href= "<?php echo esc_url( add_query_arg([ 'page' => 'bp-groups', 'create' => 'create-from-admin', 'action' => 'edit', ], admin_url( 'admin.php' ) ) ); ?>" ><?php _e( 'New Group' , 'buddyboss' ); ?></a> <?php endif ; ?> </h1> <?php endif ; ?> <?php // If the user has just made a change to an group, display the status messages. ?> <?php if ( ! empty ( $messages ) ) : ?> <div id= "moderated" class = "<?php echo ( $is_error ) ? 'error' : 'updated'; ?>" ><p><?php echo implode( "</p><p>" , $messages ); ?></p></div> <?php endif ; ?> <?php if ( $group ->id ) : ?> <form action= "<?php echo esc_url( $form_url ); ?>" id= "bp-groups-edit-form" method= "post" > <div id= "poststuff" > <div id= "post-body" class = "metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>" > <div id= "post-body-content" > <div id= "postdiv" > <div id= "bp_groups_name" class = "postbox" > <h2><?php _e( 'Name and Description' , 'buddyboss' ); ?></h2> <div class = "inside" > <label for = "bp-groups-name" class = "screen-reader-text" ><?php /* translators: accessibility text */ _e( 'Group Name' , 'buddyboss' ); ?></label> <input type= "text" name= "bp-groups-name" id= "bp-groups-name" value= "<?php echo esc_attr( stripslashes( $group_name ) ) ?>" /> <div id= "bp-groups-permalink-box" > <strong><?php esc_html_e( 'Permalink:' , 'buddyboss' ) ?></strong> <span id= "bp-groups-permalink" > <?php bp_groups_directory_permalink(); ?> <input type= "text" id= "bp-groups-slug" name= "bp-groups-slug" value= "<?php bp_group_slug( $group ); ?>" autocomplete= "off" > / </span> <a href= "<?php echo bp_group_permalink( $group ) ?>" class = "button button-small" id= "bp-groups-visit-group" ><?php esc_html_e( 'Visit Group' , 'buddyboss' ) ?></a> </div> <label for = "bp-groups-description" class = "screen-reader-text" ><?php /* translators: accessibility text */ _e( 'Group Description' , 'buddyboss' ); ?></label> <?php wp_editor( stripslashes ( $group ->description ), 'bp-groups-description' , array ( 'media_buttons' => false, 'teeny' => true, 'textarea_rows' => 5, 'quicktags' => array ( 'buttons' => 'strong,em,link,block,del,ins,img,code,spell,close' ) ) ); ?> </div> </div> </div> </div><!-- #post-body-content --> <div id= "postbox-container-1" class = "postbox-container" > <?php do_meta_boxes( get_current_screen()->id, 'side' , $group ); ?> </div> <div id= "postbox-container-2" class = "postbox-container" > <?php do_meta_boxes( get_current_screen()->id, 'normal' , $group ); ?> <?php do_meta_boxes( get_current_screen()->id, 'advanced' , $group ); ?> </div> </div><!-- #post-body --> </div><!-- #poststuff --> <?php wp_nonce_field( 'closedpostboxes' , 'closedpostboxesnonce' , false ); ?> <?php wp_nonce_field( 'meta-box-order' , 'meta-box-order-nonce' , false ); ?> <?php wp_nonce_field( 'edit-group_' . $group ->id ); ?> </form> <?php else : ?> <p><?php printf( '%1$s <a href="%2$s">%3$s</a>' , __( 'No group found with this ID.' , 'buddyboss' ), esc_url( bp_get_admin_url( 'admin.php?page=bp-groups' ) ), __( 'Go back and try again.' , 'buddyboss' ) ); ?></p> <?php endif ; ?> </div><!-- .wrap --> <?php } |
Changelog
Version | Description |
---|---|
BuddyPress 1.7.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.