Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Matt Harris

Forum Replies Created

Viewing 7 posts - 1 through 7 (of 7 total)
  • Matt Harris in reply to:
    New Posts Are Not Being Cached
    #209854

    Just to head off some preliminary questions: the custom post type is being added through the admin panel as normal. Im not importing or programatically creating anything.

    Matt Harris in reply to:
    Custom order of post meta options
    #195804

    Ok I got this working! Maybe not the best way possible but it works. Here is what I have done:

    function filter_input_object($input_object, $sfid) {
       
     	if(($input_object['name']!='_sfm_colors')||($input_object['type']!='select')) {
     		return $input_object;
     	}
      
      if(!isset($input_object['options'])) {
    		return $input_object;
    	}
      
      // Move Green To Top
      $key = array_search('Green', array_column($input_object['options'], 'value'));
      $top = $input_object['options'][$key];
      unset($input_object['options'][$key]);
      array_unshift($input_object['options'], $top);
      
      // Move All Colors Back to Top
      $key1 = array_search('', array_column($input_object['options'], 'value'));
      $top1 = $input_object['options'][$key1];
      unset($input_object['options'][$key1]);
      array_unshift($input_object['options'], $top1);
      
      return $input_object;
    }
    
    add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);

    If there is a cleaner way I am interested, but this does work.

    Matt Harris in reply to:
    Custom order of post meta options
    #195788

    I saw that, but I am not trying to enter a new option, just trying to move an option. Yes, since Ross wrote the Git, maybe he has some answers. I can make his Git work, I’m just trying to build on it.

    Matt Harris in reply to:
    Custom order of post meta options
    #195780

    It enters a blank option in the drop down in the correct place. So the array_splice is working as intended, but not outputting any info.

    Matt Harris in reply to:
    Custom order of post meta options
    #195760

    No that’s not the entire code i was using, I was trying to show the filter and function I was using to try and access the object value. I have based my attempts on this github code.

    I have tried this:

    function filter_input_object($input_object, $sfid) {
       
     	if(($input_object['name']!='_sfm_colors')||($input_object['type']!='select')) {
     		return $input_object;
     	}
      
      if(!isset($input_object['options'])) {
    		return $input_object;
    	}
      
      foreach($input_object['options'] as $option) {
    	   $green = $option->value == 'Green';
      }
      
      array_splice( $input_object['options'], 1, 0, array($green) );
    	
    	return $input_object;
    }
    
    add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);

    It returns blank

    I just tried this:

    function filter_input_object($input_object, $sfid) {
       
     	if(($input_object['name']!='_sfm_colors')||($input_object['type']!='select')) {
     		return $input_object;
     	}
      
      if(!isset($input_object['options'])) {
    		return $input_object;
    	}
      
     $green = $input_object->value == 'Green';
      
     array_splice( $input_object['options'], 1, 0, array($green) );
    	
    	return $input_object;
    }
    
    add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);

    It also returns blank

    Matt Harris in reply to:
    Custom order of post meta options
    #195703

    Yes. So for example, I am using:

    function filter_input_object($input_object, $sfid) {
     
      if(($input_object['name']!='_sfm_colors')||($input_object['type']!='select')) {
       return $input_object;
      }
     	
      if(!isset($input_object['options'])) {
        return $input_object;
      }
     
     }
     add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);

    But when I try to access a specific option, I have not been able to do so with success. I am not sure of the array structure which is part of the issue.

    Matt Harris in reply to:
    Custom order of post meta options
    #195635

    Ok so I found a a script you have put together to filter the options a bit. However, I am having trouble accessing the specific values I want to move around. For example, if I have a select field named “colors” and have an array array('blue', 'green', 'yellow') but I want ‘green’ to be listed at the top, how do I access that value? I have tried the following with no luck:

    $input_object['options']->value="green';

    foreach ($input_object['options'] as $option) {
      array_unshift($input_object['options'], $option->value='green'); // returns blank
    }

    So how do I specify a certain value that I want to move? Thanks!

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