Support

Account

Forum Replies Created

  • I apologize but I only now have a way to post my solution, maybe it can be useful to someone.

    In the meantime, thank you John for the support.

    Here is my solution to the problem:

    $new_user_id = wp_insert_user($userdata);
    $value = json_decode($response['body'], true)['Id'];
    // get value from response you want to set
    update_field('field_60084ad3970a8', $value0, 'user_'.$new_user_id);
  • I entered the string here, is that correct?

    
    // A new user has been created
                $new_user_id = wp_insert_user($userdata);
                // get value from response you want to set
                update_field('field_60084ad3970a8', $value, 'user_'.$new_user_id);
                // Assign editor role to the new user (so he can access protected articles)
                wp_update_user(
                    array(
                        'role' => 'editor'
                    )
                );
                // Load the new user info
                $user = new WP_User ($new_user_id);
    

    I did a test but I don’t populate the field, I attach image as an example (this user externally has an id 970)

    User ID (back WP)

  • For those interested in the feature, here’s how it worked for me.

    function.php

    
    // Loop Gallery Cat1
    
    function my_custom_gallery_cat1() {
        query_posts(array(
            'post_type' => 'gd_project',
            'orderby' => 'rand',
            'posts_per_page' => 10,
            'tax_query' => array(
                array (
                    'taxonomy' => 'gd_projectcategory',
                    'field' => 'slug',
                    'terms' => 'example-terms',
                )
            ),
        ));
        ?> <div class="masonry">
        <?php
        while (have_posts()) : the_post();
            $image_field = get_field('image');
            $image_url = $image_field['url'];
            $image_alt = $image_field['alt']; ?>
            <div class="grid-item">
            <a href="<?php echo get_permalink( $post->ID ); ?>" target="_blank">
            <img src="<?php echo esc_url($image_url); ?>" alt="<?php echo esc_attr($image_alt); ?>" />
            <h4><?php the_field( 'title' ); ?></h4>
            </a>
            </div>
        <?php endwhile; ?>
        </div> <?php
    }
    add_shortcode('example-terms', 'my_custom_gallery_cat1');
    

    single-example.php

    
    <div class="container-fluid">
    <div class="row">
    <?php echo do_shortcode('[categoria]');?>
    </div>    
    </div>
    
  • I made this filter:

    <?php
    $args = [  
    'post_type' => 'project',
    'post_status' => 'publish', 
    ];
                
    $loop = new WP_Query( $args ); 
                    
    while ( $loop->have_posts() ) { $loop->the_post(); 
    $video = get_field('embed_1', get_the_ID());
    print $video;  
    }
                
    wp_reset_postdata();
                
    ?>

    But now I would like to be able to add other custom fields like embed_1, embed_2 and embed_3 to this.

    How can I do it?

  • Great John! It was just what I was looking for but only that my dynamic was much more confused.

    I take this opportunity for a further question of this functionality.

    Using the same condition but also adding Field C as the third variable

    I’m trying this:

    <?php
    	$value_a = get_field('warning_limit');
    	$value_b = get_field('closing_limit');
    	$value_c = get_field('number_members');
    	if ($value_c >= $value_a) {
    	echo("Limited tickets");
    	}
    	elseif ($value_c == $value_b) {
    	echo("Tickets sold out");
    	} else {
    	echo("Tickets available");
    	}
    ?>

    Except that the second part is not working at the moment, I certainly did something wrong

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