• Resolved Reuven.g

    (@reuveng)


    I am trying to add a a check box to the Add New User form in my MU
    site.
    I use the signup_extra_fields action hook to add the checkbox in the end of the user registration form:

    function japanese_toggle_callback($errors) {
        $html = '<label for="send_japanese" id="jap_label"><input type="checkbox" id="send_japanese" name="send_japanese" value="1" ' . checked(1, get_option('send_japanese'), false) . '/>';
        $html .= ' Add Japanese user</label>';
        echo $html;
    }
    add_action('signup_extra_fields', 'japanese_toggle_callback', 10, 1);

    I put this code in to a plugin file but the checkbox do not appear unless I call the do_action on the signup_extra_fields hook.
    I tried to play around with the priority of the hook with no luck.
    please advise

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Reuven.g

    (@reuveng)

    Is there a way to move this topic to: Plugins and Hacks?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    This is the right place for Multisite (be it a hack or not).

    I put this code in to a plugin file but the checkbox do not appear unless I call the do_action on the signup_extra_fields hook.

    Have you read this? https://wordpress.stackexchange.com/questions/73258/how-to-customize-the-wp-signup-php-for-a-multisite-network

    Thread Starter Reuven.g

    (@reuveng)

    My mistake was that this hook ‘signup_extra_fields’ is intended for the front-end page registration form, and I was looking to change the user-new.php registration.
    I wasn’t even checking the front-end,
    Thank you, the hooks in this post are intended to be used in the regular installation of WordPress, I use a multisite so they don’t
    do any good for me.
    After your suggestion I reread that post, and checked the front-end page registration, found the checkbox there.
    For the new user form in the back-end I found the hook user_new_form
    and it work good just changing the hook to:

    function japanese_toggle_callback($errors) {
        $html = '<label for="send_japanese" id="jap_label"><input type="checkbox" id="send_japanese" name="send_japanese" value="1" ' . checked(1, get_option('send_japanese'), false) . '/>';
        $html .= ' Add Japanese user</label>';
        echo $html;
    }
    add_action('user_new_form', 'japanese_toggle_callback', 10, 1);

    I did’t do any validation or registration of the value in the checkbox because I only need to check if it is submitted.

    how to use checkboxes on register page in theme my login? and after registration it shows the values on profile page also? any help?

    Thread Starter Reuven.g

    (@reuveng)

    Hello Ravikas,
    Are you looking to modify the login or the registration page?
    What is the type of field you want to add?
    Do you want to save one of the built in WordPress fields, like
    first name, or last name, what field do you want to save?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding check box to the new user registration’ is closed to new replies.