Title: Update programatically
Last modified: August 22, 2016

---

# Update programatically

 *  Resolved [yellowhippo](https://wordpress.org/support/users/yellowhippo/)
 * (@yellowhippo)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/update-programatically/)
 * I’m trying to update the meta field automatically when a user registers. I also
   have a category being created automatically on registration. It looks something
   like this:
 *     ```
       function my_pmpro_after_checkout($user_id) {
   
       //create new category for this level
           $term = wp_insert_term(
               $level_name,    //level name is still their username
               'category',
               array(
                   'description'	=> 'PMPro Category',
                   'slug' 		=> sanitize_title($level_name)
               )
           );
   
           $term_id = $term['term_id'];
   
           if(empty($term_id))
               return false;   //there was an error adding the category
   
        //Restrict columnist to category
           update_user_meta( $user_id, '_access', $level_name);
       }
       add_action('user_register','my_pmpro_after_checkout');
       ```
   
 * The meta is saving to the user, but it will not update in the dropdown menu. 
   Any ideas?
 * I’ve also tried
 * `update_user_meta( $user_id, '_access', $level_name, $_POST['allow']);`
 * and
 * `update_user_meta( $user_id, '_access', $_POST['allow'], get_user_meta( $user_id,
   $level_name, true ) );`
 * Any help would be greatly appreciated.
 * [https://wordpress.org/plugins/restrict-author-posting/](https://wordpress.org/plugins/restrict-author-posting/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Jam Viet](https://wordpress.org/support/users/mcjambi/)
 * (@mcjambi)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/update-programatically/#post-5462947)
 * `update_user_meta( $user_id, '_access', $level_name);`
 * as in this code, `$level_name` should be array of category_id and should work
   as aspect !

Viewing 1 replies (of 1 total)

The topic ‘Update programatically’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/restrict-author-posting_f2eec9.svg)
 * [Restrict Author Posting](https://wordpress.org/plugins/restrict-author-posting/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/restrict-author-posting/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/restrict-author-posting/)
 * [Active Topics](https://wordpress.org/support/plugin/restrict-author-posting/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/restrict-author-posting/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/restrict-author-posting/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Jam Viet](https://wordpress.org/support/users/mcjambi/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/update-programatically/#post-5462947)
 * Status: resolved