Support

Account

Home Forums Front-end Issues Front-end posting and user registration in one form

Helping

Front-end posting and user registration in one form

  • First of all I want to thank Elliot for this awesome plugin and all devs on this forum for the plenty answers I found here and used in my work. But for now I ran into problem I can’t resolve. Please give an advice.
    I need two forms in one with two actions. Guest creates post through form and register himself.
    I got two groups of ACF “Company representative registration” with 2 fields: email(which is login too) and password and “Company description”.

    I tried to combine this thread for creating user with existing form for creating post, but could not get it work together.

    I guess I need smth like, but how?

    if ( ! is_user_logged_in() ) {
            if ( email_exists( $author_email ) ) {
                // email has an account
                require_once(ABSPATH . WPINC . '/ms-functions.php');
                $userid = get_user_id_from_string( $author_email );
            }
            else {
                // create an account with acf_form #1
                
                ) ;
                wp_set_password($last_name, $user_id);
            }
        }
        else {
            $user_id = get_current_user_id();
        }
    
        // create custom post type "company" with acf_form #2
        
       }
    
        //SAVE THE POST
        $pid = wp_insert_post($new_post, true);
    
        
       //POST THE POST YO
       do_action('wp_insert_post', 'wp_insert_post');

    and just 1 button for both actions.

  • Hi @sabrinaze,

    Thanks for the post.

    I believe the logic to check if the email has an account should be added to your template where you are calling the acf_form() function.

    You can then leave the wp_insert_post() action to the acf/pre_save_post so that the post data can be added to the database once the user passed the validation.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Front-end posting and user registration in one form’ is closed to new replies.