How to add Front End Custom Fields
-
Hello There,
We have Added custom fields using ACF and its showing up there in the Backend Post Editor. But we that that field to be set as BuddyPress form fields values like suppose.
Here city is the field which exists in BuddyPress profile field and we want to set the custom field there when user creates new doc or edits etc.
$myfield = xprofile_get_field_data( ‘city’, $bp->loggedin_user->id );
Like below is the code we are using but its not workingfunction run_when_post_published($post) { // your function code here global $wpdb; if(!wp_is_post_revision($post->ID) && $post->post_type == 'bp_doc') { global $bp; $myfield = xprofile_get_field_data( ‘city’, $bp->loggedin_user->id ); echo $myfield; add_post_meta($post->ID, 'city_meta', $myfield , true); } } // replace {custom_post_type_name} with the name of your post type add_action('new_to_publish', 'run_when_post_published'); add_action('draft_to_publish', 'run_when_post_published'); add_action('pending_to_publish', 'run_when_post_published');
Please help it’s urgent
Thanks
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘How to add Front End Custom Fields’ is closed to new replies.