Support

Account

Forum Replies Created

  • @dushakov Yes I did, it seems to work as needed now.

  • Any ideas on this? Still can’t get the title added from the ACF form.

  • HI @James

    Thank you for you reply.

    I’ve changed the syntax and also updated to acf/save_post. All still being saved correctly and the new posts created, but I still can’t get the title set.

    Here’s how I’m trying to fetch it:

    
    $cpt_title = get_field('name', $post_id);
      
        // Create a new post
        $post = array(
            'post_status'   => 'publish',
            'post_type'     => 'my_custom_post',
            'post_title'    => $cpt_title,
            'post_name'   => wp_unique_post_slug( sanitize_title( $cpt_title ) ),
            'post_author' => $current_user->ID,
        );  
    

    But it doesn’t set the title and understandably the slug.

  • Thanks Elliot, I tried incorporating this but while it pulls the post in with those values, I also get post name from this:
    At <a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
    …coming through from another post which doesn’t have any of the values I’m checking for.

    Does this look right or do I need a 'relation' => 'OR', before each array?

    <?php
    $posts = get_posts(array(
    	'post_type' => 'spot',
    	'posts_per_page' => -1,
    	'meta_query' => array(
    		'relation' => 'OR',
    		array(
    			'key' => 'offer_title_1',
    			'compare' => 'EXISTS'
    		),
    		array(
    			'key' => 'offer_title_2',
    			'compare' => 'EXISTS'
    		),
    		array(
    			'key' => 'offer_title_3',
    			'compare' => 'EXISTS'
    		)
    	)
    ));
     
    if($posts)
    {
    	foreach($posts as $post)
    	{ ?>
    
    	<div class="one-third">
    		<?php if(get_field('offer_title_1')) { ?>
    			<a href="<?php echo get_permalink(); ?>"><h3><?php the_field('offer_title_1') ?></h3></a>
    		<?php } ?>
    
    		<?php if(get_field('offer_title_2')) { ?>
    			<a href="<?php echo get_permalink(); ?>"><h3><?php the_field('offer_title_2') ?></h3></a>
    		<?php } ?>
    	
    		<?php if(get_field('offer_title_3')) { ?>
    			<a href="<?php echo get_permalink(); ?>"><h3><?php the_field('offer_title_3') ?></h3></a>
    		<?php } ?>
    	At <a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
    	</div>
    	<?php }
    }
    ?>
     

    Thanks for your help with this Elliot. Your plugin rocks!

  • Hi, the values could be anything. I only really want to pull in and list posts with any of the keys present, not by value.

    So each of the 3 offers have a title, description and expiry date and I only want to pull in posts with any titles completed – the value of which will be always changing against the keys and could be anything eg, 2 for 1 on thursdays etc. I just need to check if a value exists for any of the keys and display the post data if it exists.

    Does this make sense?

  • Ok great. Kinda have it working, but my code:

    
    <?php
    $posts = get_posts(array(
    	'post_type'		=> 'spot',
    	'posts_per_page'	=> -1,
    	'meta_query'		=> array(
    		'relation' => 'OR',
    		array(
    			'key' => 'offer_title_1',
    			'compare' => '='
    		),
    		array(
    			'key' => 'offer_title_2',
    			'compare' => '='
    		),
    		array(
    			'key' => 'offer_title_3',
    			'compare' => '='
    		)
    	)
    ));
     
    if($posts)
    {
    	foreach($posts as $post)
    	{
    		echo the_title();
    	}
    }
    ?>
    

    is pulling two posts in, one which has one of these meta values and one does not. Trying to work out why it is pulling in one correct and one incorrect.

  • Hi,

    I’m getting this on all edit pages and posts (even if no custom fields associated on those types)

    migrateWarnings
    ["jQuery.attrFn is deprecated", "jQuery.browser is deprecated"]
    	"jQuery.attrFn is deprecated"
    	"jQuery.browser is deprecated"

    On the post edit screens, I get acf-loading icons constantly spinning where acf fields would normally come in. It hangs forever and also disables all standard WP functionality eg, add featured image, switch between Visual or Text etc. Screen tab at top… nothing works/appears.

  • Also is there a way to remove the submit button? I’m already using this inside a form in the front-end, so only want the field to be part of the existing form, rather than creating a form within a form.

    Still can’t get the form saving the data wwhen added front-end.

  • It was true originally, but I tested it with false and pasted here the latest code.

    Even when set to true, I still can’t get it working.

    
    <?php 
    $options = array(
    post_id' => $post->ID,
    'field_groups' => array(),
    'form' => true,
    'form_attributes' => array(
       'id' => 'spot',
       'class' => '',
       'action' => '',
       'method' => 'post',
     ),
    'return' => add_query_arg( 'updated', 'true', get_permalink() ),
    'html_before_fields' => '',
    'html_after_fields' => '',
    'submit_value' => 'Update',
    'updated_message' => 'Post updated.'
    );
    
    acf_form( $options ); 
    ?>
  • Certainly have. I also had to add the admin styles snippet into functions too. Is there a way to test if the acf_form_head has been done correctly?

    Although, I suspect the issue is trying to get my custom post type linked to the acf form.

  • Actually, if I add a value in the back-end of the custom post, it shows correctly in the front-end form when I go back to edit it – so that works.

    It’s just a case of getting the acf value to save in my custom post type post.

  • Yeah I got it working now. Thanks man.

  • This:

    $other_page = 'user_' . $current_user->ID;
    var_dump($other_page);
    $values = get_field('favourite_movie', $other_page);
    var_dump($values);

    Gave me this:

    string(6) "user_3" bool(false)

  • An Woocommerce ‘My Account’ file. Sits in mytheme/woocommerce/.

    Like I say, it works fine when I have the ID of the page in there so it can communicate fine with the global data. Just cannot get username as $other_page.

  • Hi Elliot,

    I’ve tried implementing like this:

    <?php
    global $current_user;
    get_currentuserinfo();
    
    $other_page = 'user_' . $current_user->ID;
    ?>
    <p><?php echo the_field('favourite_movie', $other_page); ?></p>

    Is this what you mean? It doesn’t seem to do anything.

    Thanks for you help with this.

    P

  • It returns this:

    string(10) “CompanyOne” bool(false)

    CompanyOne is the username of the current logged in user.

  • Hi Nuro, that’s a no on that but thank you for your suggestion.

    It’s crazy. It seems so easy yet just doesn’t work.

    Trying it normally with manual ID of page like:

    <?php
    $other_page = 890;
    ?>
    <?php the_field('field_name', $other_page); ?>

    …works great so the data IS being passed from the other page. I then had another idea of trying this way:

    <?php
    global $current_user;
    get_currentuserinfo();
    $username = $current_user->user_login;
    $other_page = $username;				
    ?>
    <p><?php the_field('favourite_movie', $other_page); ?></p>

    …which didn’t work either.

    The username of the current user IS also working when I ask for it conventionally:

    <?php global $current_user;
          get_currentuserinfo();
          echo 'Username is ' . $current_user->user_login . "\n";
    ?>

    Baffled.

    Elliot, how can I debug this? I’ve tried dumping the values:

    <?php
    global $current_user;
    get_currentuserinfo();
    
    $other_page = $current_user->user_login;
    $values = get_field('favourite_movie');
    var_dump($values);
    ?>

    and get bool(false) printed out?

  • Hi Elliot,

    Thanks for you help with this. I’ve tried your suggestion which broke my page – assuming it was because $other_page = $current_user->user_login was missing a ; on the end?

    Anyhow, this is what I have so far but still doesn’t pull anything in from the ACF field in the page:

    <?php 
           global $current_user;
           get_currentuserinfo();
    										$other_page = $current_user->user_login;
    	if( is_page( $other_page ) ) {
    	the_field('favourite_movie', $other_page);
    	}
       ?>
Viewing 19 posts - 1 through 19 (of 19 total)