Title: Creating Post via code
Last modified: September 1, 2016

---

# Creating Post via code

 *  Resolved [evbof7734](https://wordpress.org/support/users/evbof7734/)
 * (@evbof7734)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/creating-post-via-code/)
 * I am writing a widgit that inserts a post into a protected area (only one special
   user can edit)
    However, I am rather new to php. Right now, my assumption is 
   that as I build $post I will need to do something like: ‘post_edit_cap’ => ??????
   but I have no idea what ?????? should be. I tried ‘post_edit_cap’ => get_user_label(“
   userlabel_1_uncleprotected”) but that did not work. Upon further examination 
   I am not surprised it did not work. As I mentioned, I am very new to php. Based
   on limited knowledge it seems to me that post_edit_cap is more than a mere integer.
   Can you help me on this? Not only would you be helping me with your own plugin,
   you would also be giving great insight into php for a noob.
 * [https://wordpress.org/plugins/wp-access-areas/](https://wordpress.org/plugins/wp-access-areas/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [evbof7734](https://wordpress.org/support/users/evbof7734/)
 * (@evbof7734)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/creating-post-via-code/#post-7472308)
 * I have continued to fiddle with things.
    I am at this point and I am stymied.
   I have setup a $post with an author, contents, and all that jazz. I then try 
   the following:
 *     ```
       $post['post_edit_cap'] = 'userlabel_1_uncleprotected';
               $post_id = wp_insert_post($post);
       ```
   
 * I have also tried double quotes.
 *  Thread Starter [evbof7734](https://wordpress.org/support/users/evbof7734/)
 * (@evbof7734)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/creating-post-via-code/#post-7472312)
 * It would seem I had set all my post array incorrectly.
    I have a very basic button
   working right now.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Creating Post via code’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-access-areas_616579.svg)
 * [Access Areas for WordPress](https://wordpress.org/plugins/wp-access-areas/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-access-areas/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-access-areas/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-access-areas/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-access-areas/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-access-areas/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [evbof7734](https://wordpress.org/support/users/evbof7734/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/creating-post-via-code/#post-7472312)
 * Status: resolved