• Resolved antoinelrx

    (@antoinelrx)


    I already submitted this ticket from my pro account but I don’t have any confirmation it worked so I try again. Sorry if it is duplicated

    Hi,?
    I’m using your acf form (pro version) to create a custom post type. At the same time I would like to create a user but I can’t make this action work.?

    I want to create a user using the first email address value in a repeater field but it does not work. How can I find this value using the cheatsheet ??
    The next actions work fine.

    Can you guide me with this please ? I did not find information about this in your documentation.?

    Kind regards

Viewing 1 replies (of 1 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    I don’t think I received any ticket about that question. Unfortunately you can’t use Template Tags for such advanced usage. You’ll have to use PHP hooks, such as acfe/form/submit (see documentation), or a hook specific to an Action.

    In the ACF Extended Forms hooks, you can loop thru repeaters just like in the front-end using have_rows(): the_row() (See ACF documentation) or directly by calling get_field('my_repeater'). You can then create a new user with wp_insert_user() (See documentation)

    Here is a usage example:

    add_action('acfe/form/submit/form=my-form', 'my_form_submit', 10, 2);
    function my_form_submit($form, $post_id){
        
        // count lines
        $line = 0;
        
        if(have_rows('repeater_field_name')):
            while(have_rows('repeater_field_name')) : the_row();
                
                // add line
                $line++;
                
                // first line only
                if($line === 1){
                    
                    // retrieve email sub field
                    $email_adress = get_sub_field('my_email');
                    
                    // create a new user
                    wp_insert_user(array(
                        'user_email' => $email_adress
                        // ...
                    ));
                    
                }
                
            endwhile;
        endif;
        
    }
    

    Hope it helps!

    Have a nice day!

    Regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Create user from email repeater’ is closed to new replies.