Problem saving a field to another
Author | Posts |
---|---|
December 29, 2013 at 1:51 am 14008 | |
Tareq Hasan | Hi. Few weeks ago I wrote a topic about populating a field with username. I retrieve an article talking about hooks: it works, but in this case I get a problem: - In the article doesn't appear how can I read username data - With that example, I can't save username data like a post tag Basically, I need to read username data from logged in users and write it just like a post tag. Any suggestion to do this? |
December 29, 2013 at 2:10 am 14012 | |
Tareq Hasan | You can get the current logged in users username like this: I am not sure what else informations do you need. |
December 29, 2013 at 2:31 am 14013 | |
Danilo | Thank you very much for quick reply, but after this, I can save it in a custom field, but not like a post tag. |
December 29, 2013 at 11:56 am 14015 | |
Tareq Hasan | Take a look at wp_set_post_terms() function. |
December 29, 2013 at 7:17 pm 14018 | |
Danilo | I’ll try to get the code. It would be good to create a new section on documentation with snippets for no-programmers… |
December 30, 2013 at 2:42 am 14029 | |
Danilo | Sorry, I can’t update post tags from given username. |
December 30, 2013 at 12:57 pm 14042 | |
Tareq Hasan | Try like this: wp_set_post_terms( $post_id, array( $user_name ), ‘post_tag’ ); add_action( ‘wpuf_add_post_after_insert’, ‘wpufe_update_tags’ ); Haven’t tested it, so not sure if it’ll work. |