Home › Forums › ACF PRO › Create new user with acf_form › Reply To: Create new user with acf_form
Hi @leuchterits
I believe you can do it by using the acf/save_post hook. But, instead of creating a post, you need to create a user using the wp_create_user() function and delete the newly created post using the wp_delete_post() function. Maybe something like this:
function my_acf_save_multiple_posts( $post_id ) {
// get the user name field
$first_name = get_field('first_name', $post_id);
// get the user name field
$last_name = get_field('last_name', $post_id);
// create the user
wp_create_user( $first_name . "_" . $last_name, 'random password here' );
// delete the unused post
wp_delete_post($post_id);
}
// run after ACF saves the $_POST['acf'] data
add_action('acf/save_post', 'my_acf_save_multiple_posts', 20);
I hope this makes sense 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.