Search

bbPress Showcase » bbPress Chat

Checkboxes and how to get them to work?

RSS

  1. Null
    User has not uploaded an avatar

    member
    Joined: May '08
    Posts: 43

    offline

    Ok, I've spend all day looking into other plugins about how they use checkboxes (unfortunately they all have different methods) to understand them and get mine working. But no luck. I know you write plugins and have a better understanding about this, so I'll try my luck here

    Ok this is what I have:
    Function A

    Function B

    add_filter('bb_current_user_can','Function A');

    I want these 2 functions to be used ONLY if a checkbox is checked in the admin page and saved. Else this should be ignored.

    In the admin page I have a form with a checkbox:

    -A normal text box here-
    <td><input type="checkbox" name="test" id="test" />

    For the submit (this submit works no change needed here):
    <p class="submit alignleft"><input name="submitIt" type="submit" value="<?php _e('Submit'); ?>" /></p>

    And of course:

    function update_blog_settings() {
    	if (isset($_POST['submitBlog'])) {
    		bb_update_option( 'blog_forum_id', $_POST['forum_id'] );
    	}
    }
    
    add_action('bb_admin-header.php','update_blog_settings');

    So when this checkbox is checked and I press submit, it should save this (and remember the chosen option) and when I enter the forum it should use function A and B. When the checkbox is unchecked, it should ignore these 2 functions.

    These checkboxes seems to work a bit different then normal textboxes. Also how can I keep the checkbox checked like I do with value="<?php echo bb_get_option( 'blog_number_of_topics' ); ?> in the normal textboxes?

    Hope you can help me!

    Posted 2 years ago #
  2. Null
    User has not uploaded an avatar

    member
    Joined: May '08
    Posts: 43

    offline

    Hmm I think I've figure it out. Need to do some more testing though.

    Greets

    Posted 2 years ago #

RSS feed for this topic

Post a reply to “Checkboxes and how to get them to work?”

You must log in to post.

keep _ck_ coding >> donate $5 <<     Theme Switcher:
32 users online from in the past 30 minutes. 16 bots 15 guests 1 members: mccawphoto
7,658 views today 8,665 yesterday 14,010 peak. Most at once 63 today 48 yesterday 131 peak. Visited today: Dickinsonjohn9, shairah27, xiaotian, _ck_, engin1984, Augustine01, MichaelGomez, mccawphoto, KitchenDip
2,240 posts in 380 topics over 63 months by 425 of 1,992 members. Latest: shairah27, Augustine01, MichaelGomez