• Resolved Gloria

    (@ggoldin)


    Hi!
    On my installation I have activated the Custom Fields and Authors add-ons.
    I have added, with the Custom Fields add-on, some custom fields to the type Advert — Create form. In case the user, into the Add Advert form, checks the “Create an account”, I would like that those custom fields are saved into the authors post type. As the email and phone number do.

    Sorry for my english mistakes, it’s not my mother tongue. Hoping I was clear enough.

    Thank you, Gloria

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    when a user checks the “Create Account” checkbox then a wpadverts_user_saved action is executed when the account is created. You can use it to create an advert-author post

    
    add_action( "wpadverts_user_saved", function( $user_id, $advert_id ) {
      if( ! $user_id ) {
        return;
      }
    
      $post_id = wp_insert_post( array(
        "post_title" => get_post_meta( $advert_id, "adverts_person", true ),
        "post_content" => "",
        "post_type" => "advert-author",
        "post_author" => $user_id,
        "post_status" => "publish"
      ) );
    
      add_post_meta( $post_id, "user_phone", get_post_meta( $advert_id, "adverts_phone", true ) );
      add_post_meta( $post_id, "user_slogan", "" );
    } );
    

    This is just a basic code to fill the builtin fields, if you have more fields in the form then you can extend the code snippet.

    Thread Starter Gloria

    (@ggoldin)

    Thank you for the help. It worked!

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

The topic ‘Custom fields into post type advert-author’ is closed to new replies.