Home Forums Plugin Support WP User Frontend Pro Conditional Logic posting to Custom Post Type

This topic is: resolved

This topic contains 7 replies, has 2 voices, and was last updated by  hatchmedia 3 years, 7 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #73826

    hatchmedia
    Participant
    Post count: 116

    Hey guys,

    Not sure if this would be possible, but is there a way to set up conditional logic and then send a post to a certain post type depending on which conditions are set?

    So, I have three forms currently which post to CPT1, CPT2 and CPT3. I want to turn this into one large form and use conditional logic to display the different fields.

    Ideally, the user will be prompted to select a CPT from a drop down. Then, depending on what they selected, it will pull fields relating to that CPT. Once they have finished filling in the form, the form should know which CPT to post to based on what the user selected originally.

    Is there a way to make this work?

    Damien

    #73964

    towhid
    Participant
    Post count: 4505

    Hello Damien,

    This is about an customization issue. To get this you have to customize the plugin. You must hire an experienced developer who can help you to find a better solution.

    And hope that If there's anything else I can do for you, you won't hesitate to let me know.

    Thanks

    #74186

    hatchmedia
    Participant
    Post count: 116

    Hi Towhid,

    Could you give me an idea of where to look please? I am happy to try a few things myself, but would appreciate a little guidance, just to get me started. ๐Ÿ™‚

    Thanks

    Damien

    #74513

    hatchmedia
    Participant
    Post count: 116

    Hello,

    I was just wondering if you could give any ideas on this please?

    Damien

    #74557

    towhid
    Participant
    Post count: 4505

    Hello Damien,

    I sincerely apologize for taking so long to respond! I am going to look into this for you and follow up the end of the day.

    Thanks

    #74574

    hatchmedia
    Participant
    Post count: 116

    Thanks Towhid,

    I appreciate it.

    Damien

    #74577

    towhid
    Participant
    Post count: 4505

    Hello Damien,

    Thanks for the reply!

    Does your three form use the similar fields? Then use this code at the bottom of the theme's functions.php

    add_action( 'wpuf_add_post_after_insert', 'change_post_type' );
    
    function change_post_type( $post_id ) {
        $post_data = array(
            'ID' => $post_id,
            'post_type' => get_post_meta($post_id,'post_type',true)
        );
        wp_update_post( $post_data );
    }

    Also, create a drop-down field. And name the field as Post Type. It will automatically convert into post_type as meta key Now, enter label1= CPT1, label2=CPT2, label3=CPT3. Check this screenshot

    Custom Post

    Hope the solution will help you to get this work.

    Please let me know if there's anything else I can do for you.

    Thanks

    #74654

    hatchmedia
    Participant
    Post count: 116

    Hi Towhid,

    From my initial testing, it looks like this is working for me! Thanks so much for the code snippet, I appreciate it.

    Damien

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

The topic ‘Conditional Logic posting to Custom Post Type’ is closed to new replies.