Support

Account

Home Forums General Issues How to check two ACF checkboxes upon WP registration using a single checkbox?

Unread

How to check two ACF checkboxes upon WP registration using a single checkbox?

  • I’m using a custom registration form for WordPress registration. I’ve added a single checkbox and need to check two ACF checkboxes on the back-end if the user checks this box.

    I’ve tried using the code below to hook into the user_register function in WordPress, but the boxes are not checked when I view the WP user under Extended Fields.

    function register_hook ( $user_id ) {
      // if custom checkbox is checked, check both of these checkboxes from acf
      if ( $_POST['checkbox'] == 'yes' ) {
        update_user_meta( $user_id, 'field_98_0', 'newsletter 1' );
        update_user_meta( $user_id, 'field_99_1', 'newseletter 2' );
      }
    }
    add_action( 'user_register', 'register_hook' );

    Any help would be greatly appreciated.

Viewing 1 post (of 1 total)

The topic ‘How to check two ACF checkboxes upon WP registration using a single checkbox?’ is closed to new replies.