Programmatic access to meta key values
-
Hi Team
I am building a solution that combines WPUF with Popup Maker and Ultimate Member Groups. To be able to post directly from WPUF to UM Groups I need to set some meta keys and values and I am able to do so through the WPUF Hidden Fields. One meta key value requires the user_id and another one requires the text of the post. See below:
$post_id = wp_insert_post( $post_data );update_post_meta($post_id, ‘_original_content’, $text);
update_post_meta($post_id, ‘_wall_id’, ‘1’);
update_post_meta($post_id, ‘_action’, ‘status’);
update_post_meta($post_id, ‘_user_id’, ‘$author_id’);
update_post_meta($post_id, ‘_group_id’, $group_id);
update_post_meta($post_id, ‘_group_moderation’, ‘approved’);I am wondering if there are hooks to problematically put the current user_id and text of the post into the meta keys.
Also it would be helpful if I can use a WordPress shortcode into a HTML field as I want the permalink in the post. I am not able to get this working with a HTML field containing [shortcode] only.
Any help is welcome.
The page I need help with: [log in to see the link]
-
problematically = programmable (sorry)
Solved it by taking a little different approach, leaving the solution here for anybody to use. I have now created a hook that posts directly into UM Groups. I use this to post comments on my blogs. See https://excellent-bid.nl/en/
function wpuf_post_umgroup( $post_id, $form_id ) {
/* Check if form contains field for _wall_id to make sure we have the correct form */
if ( isset($_POST[‘_wall_id’])) {
/* Build the post content by adding the referer URL to the comment and update the post */
$lv_comment = $_POST[‘_my_comment’] . PHP_EOL . PHP_EOL . home_url() . wp_get_referer();$lv_post = array();
$lv_post[‘ID’] = $post_id;
$lv_post[‘post_author’] = get_current_user_id();
$lv_post[‘post_content’] = $lv_comment;
wp_update_post( $lv_post );/* Update the post meta fields needed for UM Groups see hidden fields in WPUF form */
update_post_meta( $post_id, ‘_original_content’, $lv_comment );
update_post_meta( $post_id, ‘_user_id’, get_current_user_id() );}
}add_action( ‘wpuf_add_post_after_insert’, ‘wpuf_post_umgroup’ );
The topic ‘Programmatic access to meta key values’ is closed to new replies.