Support

Account

Forum Replies Created

  • No diec @hube2 unfortunately πŸ™

    I had bad regex in finding keys in json file, this one is correct

    \"key\": \"field_.*\"

    because with “field_.*” I also selected “conditional_logic” fields (just refs and that’s just fine) πŸ™

    File is semantically OK (AFAIK – no dups for sure) but also when I add this “Title” field in json (on position where I need it), increase timestamp on modified field admin interface is not reflecting the change (and no sync option is available) (there are other field groups that I get sync option)

    So now I’m lost with this issue more then before πŸ™

  • Also,

    I’ve picked up json file that got saved in acf-json dir and I find out that field_XXX is not unique (like 30% duplicates) ? .. or should I ditch all this and start from scratch?

    desc

  • Thanks @slickorange for code, simple and do the job!

  • OK, I’ve come to this problem from another angle and did resolve that part like this:

    
    // =============================
    // frontend single ifcc logic 
    // =============================
    
    function cpt_front() {
        global $post;
        // this here is for making sure not to fall in redirect loop trick :)
        if( $post->ID == get_option('woocommerce_myaccount_page_id') ){
            return;
        }
    
        if ( $post->ID == 53 && !is_admin() ) {
    
            if( is_user_logged_in() ){
    
                acf_form_head();
                add_action( 'the_content', 'callsall' );
    
            } else {
                wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); 
                exit();            
            }
    
        }
    }
    
    add_action( 'template_redirect' , 'cpt_front' );
    

    this is only thing in my plugin to get handle on my cpt here, not from template file..

    the only ugly thing here is hardcoded postID inside,, but that would need to be saved in some variable and read..

    thanks

  • Sure,

    I call this in my custom plugin..

    
    /* acf post generate */
    
    function create_acf_post( $post_id )
    {
        // check if this is to be a new post
        if( $post_id != 'new' )
        {
            return $post_id;
        }
    
        // Create a new post
        $mytitle = get_user_meta( get_current_user_id(), 'nickname', true ) . ' - ' . $_POST['fields']['field_547959d79b64c'];
        $post = array(
            'post_status'  => 'draft' ,
            'post_title'  => $mytitle,
            'post_type'  => 'ifcc'
        );  
    
        // insert the post
        $post_id = wp_insert_post( $post );
    
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );    
    
        $user_id = get_current_user_id();
        update_user_meta( $user_id, 'done_free', '1' );     
        // wp_redirect('/');
    
        // return the new ID
        return $post_id;
    }
    
    add_filter('acf/pre_save_post' , 'create_acf_post' );
    

    and that is fired on frontend while after couple of pars are meet,, frontend, is single, is custom post (ifcc) and logged in..

    
    // =============================
    // frontend single ifcc logic 
    // =============================
    
    function cpt_front($query) {
        if ( !is_admin() && $query->is_main_query() ) {
            if ($query->is_single() && $query->post_type == 'ifcc' ) {
                if( is_user_logged_in() ){
                    $user_id = get_current_user_id();
                    $usernick = get_user_meta( $user_id, 'nickname', true );
                    update_field('submitee_name', $usernick);
                    $free = get_user_meta( $user_id, 'done_free', true );
                    if( $free == '1' ){
                        echo 'need to buy additional licence';
                    } else {
                        get_template_part( 'content', get_post_format() );
                        $args = array(
                            'post_id' => 'new',
                            'field_groups' => array( 68 )
                        );
                        acf_form( $args );
                    }
                } else {
                    // echo get_permalink( get_option('woocommerce_myaccount_page_id') );
                    echo do_shortcode('[woocommerce_my_account]');
                }
            }
        }
    }
    
    add_action('pre_get_posts','cpt_front');
    

    so, everything works cool, and post is inserted in backend and all, but redirect part if off somehow,,

    thanks

  • Hi,
    I intentionaly commented it out cause it does not work… that part I would like to change but don’t know to what to work πŸ™‚

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