Support » Fixing WordPress » Radio button to update user_meta field

  • I want to do something very simple. But I’m having a hard time getting it to work.

    I want to have some radio buttons that a user can choose from. When the user makes a choice, I need them to update a metakey value in the wp_usermeta table.

    I’m trying to user the $wpdb command but I can’t get it to work because I don’t know how to pass the user’s choice into it.

    <form action="" method="post">
        <p class="form-row form-row-first">
        <label for="membership"><?php _e( 'Current Membership, ' ); _e( $user->membership ); ?> <span class="required">*</span></label>
        <input type="radio" id="Free" name="membership" value="1" onChange="this.submit()"/> Free
        <input type="radio" id="Price" name="membership" value="2" onChange="this.submit()"/>Price <font class="required">*</font>
        <input type="radio" id="High" name="membersip" value="3" onChange="this.submit()" /> High <font  class="required">*</font>
        <input type="hidden" name="membership" value="" />
      <div class="clear">
    	<p><input type="submit" class="button" name="save_account_details" value="<?php _e( 'Save changes', 'woocommerce'); ?>" /></p>
    	<?php wp_nonce_field( 'save_account_details' ); ?>
    	<input type="hidden" name="action" value="save_account_details" />
  • The topic ‘Radio button to update user_meta field’ is closed to new replies.