Support

Account

Forum Replies Created

  • I was able to resolve this issue by creating an array and then targeting the array column of LABEL.

    if( get_field('degrees', $post->ID) ) {
    	while ( have_rows('degrees', $post->ID) ) : the_row();
    		 $showDegree = array();
    		 $showDegree[] = get_sub_field('degree_select');
    		 $foo = implode(', ', array_column($showDegree, 'label'));
    			$listinfo .= ', ' . $foo . '';
    	endwhile;
    }
  • Ok, so the difference was the fact that I need to be calling the date in Ymd format instead of F j, Y.

    Once I changed that to what you wrote, it appears to working as intended.

    Thanks!

  • I figured out the solution. I was to use array_column which helped me focus on that single column of information.

    <?php if( get_field('degrees') ) {
       while ( have_rows('degrees') ) : the_row();
          $array[] = get_sub_field('degree_select'); 
       endwhile;
       $foo = implode(', ', array_column($array, 'label'));
       echo $foo;
       }								
    ?>

    You can learn more about those here:
    https://www.php.net/manual/en/function.array-column.php

  • I reworked my code to look like this and everything is working so far!

    <?php
    /**
     * Shortcode: [deptlist department=""]
     * Description: This is how stuff works with parameters
     */
    
    function dept_option($atts){
    	
    	extract(shortcode_atts( array(
    		'department' => 'Legal Studies',
    	
    	), $atts ));
    	$myfinalcode = '"' . $department . '"';
    	
    	$args1 = array(
    		'meta_key' => 'last_name',
    		'orderby' => 'meta_value',
    		'order' => 'ASC',
    		'exclude' => array(1,8,9),
    		'meta_query' => array(
    			'relation' => 'AND',
    			'department' => array(
    				'key' => 'department',
    				'value' => $myfinalcode, 
    				'compare' => 'LIKE',
    			),
    		)
    	);
    	$subscribers = get_users($args1);
    		echo '<ul>';
     			foreach ($subscribers as $user) {
     			echo '<li>' . $user->display_name.' ['.$user->phone_number . ']</li>';
     			}
    		echo '</ul>';
    	
    // ENDING ROW	
    }
    add_shortcode( 'deptlist', 'dept_option' );
    ?>
  • Ok, so I think I might have solved it. Please let me know if this is the best way tho…

    $values = get_field('choose_directory');
    if($values)
    {
    	echo '<ul>';
     
    	foreach($values as $value)
    	{
    	   $user_db = $value['ID'];	
               
               echo '<li>' . $value['display_name'] . '</br>';
               the_field('phone_number', 'user_'. $user_db );
               echo '</li>';
    	}
     
    	echo '</ul>';
    }
  • Hi, still totally lost on this.

    I have updated the query to look like this:

    <?php
    $args = array(
    'meta_query' => array(
            'relation' => 'AND',
    			array(	
    			'meta_key' => 'department',
    			'meta_value' => 'Social Work',
    			'meta_compare' => '=',
    			),
    			
    			array(
    			'meta_key' => 'last_name',
    			'orderby' => 'meta_value',
    			'order' => 'ASC',
    			'exclude' => array(1,8,9),
    			),	
      )
    );
    
    // The Query
    $user_query = new WP_User_Query( $args );
    
    // User Loop
    if ( ! empty( $user_query->results ) ) {
    	foreach ( $user_query->results as $user ) {
    		um_fetch_user( $user->id );	
    ?>

    So the way I read this is that it should be looking for users that have “SOCIAL WORK” checked off in the “DEPARTMENT” ACF field that I created….(its a checkbox field).

    AND, it should then look at the USER LAST NAME, and ORDER those in ASC order.

    However when I do this code, I still get tons of users listed linked to all kinds of departments, not just ones that include SOCIAL WORK as I want.

    Please help!

  • Yes, I understand that I could use acf_form(). However that just spits the fields out in a list. It doesn’t give me any control over where the fields show up.

    I have certain fields that only will only be seen IF they are a certain level of member to my site. So I have to wrap those items inside special code.

    acf_form() doesn’t give me that kind of control…at least as far as I know.

    Therefore, I would like to generate the fields manually. I just need some help.

  • @anamika Did you ever find a solution?

    I want to use repeater fields on user profile front end pages as well.

  • @James,

    Yea that doesn’t help me because I really want to format the layout of the fields. If I just display the fields like that I can’t control anything and it just spits them out 1 by 1.

    So far, I’ve managed to write this up: which works on the front end nicely… but it does NOT save the image to the user’s profile.

    <?php
    	$field_key = "field_56a256d53721e";
    	$field = get_field_object($field_key, 'user_'.$current_user->ID);
    	
    	if( $field )
    	{
    		echo '<input type="file" id="acf-' . $field['key'] . '" name="acf[' . $field['key'] . ']">';
    	}							
    ?>

    Do you have maybe something more complete that could help me with this issue?

    Here is a screenshot of how I have my file ACF field set up:

    Background Image Upload

  • ok I think I was able to solve this one.

  • Ok well if the image upload field has a name of: logo_icon
    … and a field key of: field_56a256ab3721d

    How do I display the image upload button for my users to click on?

  • Sure thing! I have trimmed it down to just the important parts I think. You’ll see that I just have it hardcoded in there at the moment. I’m not sure how to display it dynamically, or SAVE the users choice.

    <?php
    /*
    Template Name: Video Set Up Page
    */
    
    acf_form_head(); 
    
    /* Get user info. */
    global $current_user, $wp_roles;
    ?>
    <!-- START THE CUSTOM SECTION -->
    
    <div id="post-218">
    	<form method="post" id="adduser" action="<?php the_permalink(); ?>">
    		<div id="acf-form-data" class="acf-hidden">
    			<input type="hidden" name="_acfnonce" value="87d0486349" />
    			<input type="hidden" name="_acfchanged" value="0" />
    		</div>
    
    <!-- START VIDEO SET UP SECTION -->		
    			<label for="email">Customer Type</label>
    			<select id="acf-field_56aba9ca0d64a" class="" name="acf[field_56aba9ca0d64a]" data-ui="0" data-ajax="0" data-multiple="0" data-placeholder="Select" data-allow_null="0" style="width: 100%;">
    				<option value="Customer">Customer</option>
    				<option value="Member">Member</option>
    				<option value="Client">Client</option>
    				<option value="Patient">Patient</option>
    				<option value="Guest">Guest</option>
    				<option value="Subscriber">Subscriber</option>
    			</select>
    
    			<input type="hidden" name="wlm_updating_profile" value="1" />
    						
    			<script type="text/javascript">
                    function MoveWLMember(){
                        try{
                            var x=document.getElementById('WishListMemberUserProfile');
                            var p=x.parentNode;
                            var s=p.getElementsByTagName('h3');
                            p.insertBefore(x,s[0]);
                        }catch(e){}
                    }
                    MoveWLMember();
                </script>
                           
                <p class="form-submit">
                    <input name="updateuser" type="submit" id="updateuser" class="submit button" value="Update Your Information" />
                    <input type="hidden" id="_wpnonce" name="_wpnonce" value="c3b5a2056a" /><input type="hidden" name="_wp_http_referer" value="/success/" />
                    <input name="action" type="hidden" id="action" value="update-user" />
                </p><!-- .form-submit -->
            </form><!-- #adduser -->
        </div><!-- .entry-content -->
    
        
    
    <!-- END OF THE CUSTOM SECTION -->
  • I am using Version 5.3.2.2. Could you please show me? I haven’t been able to convert the other samples I have read in the forum to work for me.

    Thanks!

  • ….. ok hold on… I think I have it…

  • Ok… so I’ve tried it a few different way and am still missing it.

    I checked my database and here is what my Hello World! post has in it for directory_news:
    a:2:{i:0;s:2:"65";i:1;s:2:"23";}

    So that’s showing me that profiles with the ID of 65 and 23 are linked to that post…

    So then I thought I followed the example that you provided with this

    
    $mine = get_posts(array(			 
        'post_type' => 'post', // "post" because I'm calling regular blog posts? 
        'meta_query' => array(
      array(  
        'key' => 'directory_news', // slug of custom field
        'value' => '65', // hardcoded it just to test
        'compare' => 'LIKE'
           )
     )
     ));

    You’ll see that instead of using the ID I just hardcoded 65 in there just to see if I could only pull that one…

    However this still spits out ALL posts.. and not the ones that have David in the relationship field.

  • So what I have done is create a new custom post type (Directory)… and this allows me to then use ACF to add in all kinds of fields about our employees. I have already created a full directory, and generated individual profile pages.. That side of it is all good.

    I added a ACF (relationship field) to my regular blog posts… this allows me to attach “profiles” that have been created inside my Directory post type. This lets me basically tag people from my directory inside my basic blog entries.

    What I want to do, is display all posts where David Smith has been “tagged”… when I am viewing David Smiths profile page. (see photo for visual)

  • Is this even possible?

    What I am trying to do is call ALL posts that have a relationship value that includes “David Smith”.

    Where “David Smith” is a post inside a custom taxonomy called “directory”.

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