Skip to:
Content
Pages
Categories
Search
Top
Bottom

Prblem to create Group Selection Form

  • Avatar of dassoubarna
    dassoubarna
    Participant

    @dassoubarna

    Beside the normal BP Groups page I want to create a page where users can select groups through check boxes and join multiple groups at a time. Though I am not an expert in PHP coding, but I try to write a code for the purpose and put it in a normal WP page through PHP code plugin. Groups are appearing in the right way, but the submit button is not working accordingly. Could any one here please guide me to resolve the problem. I am using buddypress 1.6.1 and my code is as follows:
    `

    <form action="” method=”post” id=”department-request-form” class=”standard-form”>
    <input type="checkbox" id="” name=”select_departments[]” value=”” />

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of dassoubarna
    dassoubarna
    Participant

    @dassoubarna

    The code in Pestbin.

    http://pastebin.com/195hwBhr

    Avatar of Boone Gorges
    Boone Gorges
    Keymaster

    @boonebgorges

    You’re using form actions incorrectly. The form `action` is intended to be a URL, not a PHP callback. You’ll need to add your server-side processor to a separate function, ideally in a separate file from the screen function. Something like:

    `
    function bbg_handle_department_join() {
    if ( isset( $_POST['department-request-submit'] ) ) {
    $submitted_departments = $_POST['select_departments'];
    // do something with the items
    }
    add_action( ‘bp_actions’, ‘bbg_handle_department_join’ );
    `

    I also urge you to implement some security checks. At minimum, use a nonce as well as an appropriate `current_user_can()` check. See https://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/ for a primer on nonces in WordPress.

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

You must be logged in to reply to this topic.