Forum Replies Created

Viewing 14 posts - 31 through 44 (of 44 total)
  • Author
    Posts
  • in reply to: Piklist saving error #3826
    justin
    Member

    I do have piklist code, but at the time of the test, i deactivated my custom plugin with the piklist code to make sure that was not the cause.

    in reply to: Database Error when adding plugin #3614
    justin
    Member

    Where did you install the plugin from? I had to manually upload the plugin, because I purchased the full version. Maybe it is only on upload, not just from the store. I do not think it maters the plugin, as long as it creates new tables.

    I have many other plugins installed.

    Most are related to my theme which includes WPBakery Visual Composer.

    Since the error only appears when I uploaded the plugins, I am not too terribly worried about it because I don’t see any adverse problems. If it is not happening for you then it might just be a conflict with one of my other plugins.

    I tried trouble shooting it by deleting the plugin and re-uploading it, but no more errors. I think that is because the tables were already created.

    Thanks for trying.

    in reply to: Widget – No such file found #3578
    justin
    Member

    Works Like a charm.

    Thanks,

    in reply to: Duplicate Select drop downs #3433
    justin
    Member

    That is exactly what the problem was. I missed that completely.

    in reply to: on_post_status and Add more #3431
    justin
    Member

    Thank you for your help.

    in reply to: on_post_status and Add more #3429
    justin
    Member

    Thank you. Did not event think about using that. The only other thing now that I am finding is that when you add another field, it is not auto-populated by the value I have inputted. They are just blank.

    in reply to: on_post_status and Add more #3421
    justin
    Member

    Ideally that would be great, but I could not figure that out. So instead I was just going to have 2 of the 3 fields in the group always be locked because I automatically set the value to the current date and the current user. But when I try and lock those two fields in the group that allows for add_more, the add more button disappears, and I can now only add a single note instead of multiple notes.

    GROUP with add more functionality set to true

    • Name (This field will be automatically set to current user, and always be locked)
    • Date (This field will be automatically set to current date and always be locked)
    • Notes (This field will never be locked-unless it was possible to lock past notes, but that is not what the code above is trying to do.)
    in reply to: Validate Unique value #3359
    justin
    Member

    Steve,

    I finally figured out why this was not working. It had to do with a plugin called php console which prevented me from seeing an error that the piklist toolbox was causing. I find that if i uninstall both php console and the toolbox, that it works, and there are no errors. Thank you so much for helping.

    (just for information on this support issue,
    https://piklist.com/support/topic/notice-trying-to-get-property-of-non-object/
    Those notices are caused by the toolbox plugin. I somehow deactivated it, is why I thought that it was solved.)

    You can close this ticket now.

    Below is code that works for anyone else that is interested.

    add_filter('piklist_validation_rules', 'check_if_unique', 11);
    function check_if_unique($validation_rules)
    {
      $validation_rules['custom_unique'] = array(
        'callback' => 'my_validate_unique'
      );
     
      return $validation_rules;
    }
     
    function my_validate_unique($file, $field, $arguments)
    {
    	global $user_id;
    
    	$user_profile_id = $user_id;
    
    	$user_query = new WP_User_Query( 
    		array( 
    			'meta_key' => 'user_custom_url'
    			,'meta_value' => $field //Works if this is replaced with 'value'
    			,'exclude' =>$user_profile_id
    		) 
    	);
    
    $userscount = $user_query->get_total();
    
      if($userscount != 1 )
      {
      return true;
      }else{
    	  return __('is not unique', 'your-text-domain');
      }
     
    }
    
    in reply to: Notice: trying to get property of non-object #3353
    justin
    Member

    I just wanted to let you know that updating to the latest beta resolved all the notices for me.
    0.9.5u.t

    Thanks

    in reply to: Validate Unique value #3352
    justin
    Member

    Hi Steve,

    I am sorry, but no mater what I try I can not get it to work. I must be missing something. I can not even get it to print_r($field), or print_r(‘test’) to work inside that function. I have now tried both $field[‘value’] and $field[‘value’][0] to no luck. With either of those every time it comes up valid. When I replace the variable with a physical string, I am able to validate the field correctly.

    Just for reference I have updated to the latest beta today and still have the problem: 0.9.5

    
    add_filter('piklist_validation_rules', 'check_if_unique', 11);
    function check_if_unique($validation_rules)
    {
      $validation_rules['custom_unique'] = array(
        'callback' => 'my_validate_unique'
      );
     
      return $validation_rules;
    }
     
    function my_validate_unique($file, $field, $arguments)
    {
    	print_r($field); //I can not find this printing anywhere on the page
    	global $user_id;
    	$user_profile_id = $user_id;
    	$user_query = new WP_User_Query( 
    	array( 
    		'meta_key' => 'user_custom_url'
    		,'meta_value' => $field['value'] //Works if this is replaced with string - ie 'value'
    		,'exclude' =>$user_profile_id
    		) 
    	);
    $userscount = $user_query->get_total();
      if($userscount != 1 )
      {
      return true;
      }else{
    	  return __('is not unique', 'your-text-domain');
      }
     
    }
    
    in reply to: Validate Unique value #3348
    justin
    Member

    Hi,

    Is the “$field” an array? When I hard-code the field value into the meta_value query, i can get the correct result, but when i use “$field” to get the current field value, it never says that the field has a duplicate.

    Here is the modified query that works if you remove “$field” and replace it with a value that you want to test against.

    
    add_filter('piklist_validation_rules', 'check_if_unique', 11);
    function check_if_unique($validation_rules)
    {
      $validation_rules['custom_unique'] = array(
        'callback' => 'my_validate_unique'
      );
     
      return $validation_rules;
    }
     
    function my_validate_unique($file, $field, $arguments)
    {
    	global $user_id;
    $the_user_id= $user_id;
      $user_query = new WP_User_Query( array( 'meta_key' => 'user_custom_url', 'meta_value' => $field, 'exclude' =>$the_user_id) );
      $users = $user_query->get_results();
    $userscount = $user_query->get_total();
      if($userscount != 1 )
      {
        return true;
      }
      else
      { 
        return __('is not unique', 'your-text-domain');
      }
     
    }
    in reply to: Notice: trying to get property of non-object #3342
    justin
    Member
    This reply has been marked as private.
    in reply to: Validate Unique value #3341
    justin
    Member

    I saved two separate user accounts to have the same field, and it did not popup an error. I wonder if I am putting the add_filter in the wrong place. I placed it at the bottom of my plugin main php page. I also tried putting it only on the bottom of the users field php page which did not work either.

    
    add_filter('piklist_validation_rules', 'check_if_unique', 11);
    function check_if_unique($validation_rules)
    {
      $validation_rules['custom_unique'] = array(
        'callback' => 'my_validate_unique'
      );
     
      return $validation_rules;
    }
     
    function my_validate_unique($file, $field, $arguments)
    {
    	$user_query = new WP_User_Query( array( 'meta_key' => 'user_custom_url', 'meta_value' => $field ) );
    	if( !empty ($user_query)){
    		return true;
    	}else{ return __('is not unique', 'text-domain');}
     
    }
    in reply to: New Conditional Bug… YAAAY! #3318
    justin
    Member

    I am having a similar issue, If the group does not have a field name, how would I reference it?

    Here is my code:

    <?php
    /*
    Title: User General
    Description: General Info for all Users
    */
    
    piklist('field', array(
    'type' => 'select'
    ,'field' => 'user_country'
    ,'value' => 'US' // Sets default to US
    ,'label' => 'Country'
    ,'choices' => array(
      'AF'=>'Afghanistan',
    'AL'=>'Albania',
    'EE'=>'Estonia',
    'ET'=>'Ethiopia',
    'FK'=>'Falkland Islands (Malvinas)',
    'FO'=>'Faroe Islands',
    'FJ'=>'Fiji',
    'US'=>'United States',
    'UM'=>'United States Minor Outlying Islands',
    'UY'=>'Uruguay',
    'UZ'=>'Uzbekistan',
    'VU'=>'Vanuatu',
    'VA'=>'Vatican City (Holy See)',
    'VE'=>'Venezuela',
    'VN'=>'Vietnam',
    'VG'=>'Virgin Islands (British)',
    'VI'=>'Virgin Islands (US)',
    'WF'=>'Wallis And Futuna Islands',
    'EH'=>'Western Sahara',
    'WS'=>'Western Samoa',
    'YE'=>'Yemen',
    'YU'=>'Yugoslavia',
    'ZM'=>'Zambia',
    'ZW'=>'Zimbabwe'
    )
    ));
    
      piklist('field', array(
        'type' => 'group'
        ,'label' => 'Address'
        ,'fields' => array(
          array(
            'type' => 'text'
            ,'field' => 'user_address_1'
            ,'label' => 'Street Address'
            ,'columns' => 12
          )
          ,array(
            'type' => 'text'
            ,'field' => 'user_address_2'
            ,'label' => 'PO Box, Suite, etc.'
            ,'columns' => 12
          )
          ,array(
            'type' => 'text'
            ,'field' => 'user_city'
            ,'label' => 'City'
            ,'columns' => 5
          )
          ,array(
            'type' => 'select'
            ,'field' => 'user_state'
            ,'label' => 'State'
            ,'columns' => 4
    		,'conditions' => array(
    			array(
    				'field' => 'user_country'
    				,'value' => 'US'
    				)
    			)
            ,'choices' => array(
              'AL' => 'Alabama'
              ,'AK' => 'Alaska'
              ,'AZ' => 'Arizona'
              ,'AR' => 'Arkansas'
              ,'CA' => 'California'
              ,'CO' => 'Colorado'
              ,'CT' => 'Connecticut'
              ,'DE' => 'Delaware'
              ,'DC' => 'District Of Columbia'
              ,'FL' => 'Florida'
              ,'GA' => 'Georgia'
              ,'HI' => 'Hawaii'
              ,'ID' => 'Idaho'
              ,'IL' => 'Illinois'
              ,'IN' => 'Indiana'
              ,'IA' => 'Iowa'
              ,'KS' => 'Kansas'
              ,'KY' => 'Kentucky'
              ,'LA' => 'Louisiana'
              ,'ME' => 'Maine'
              ,'MD' => 'Maryland'
              ,'MA' => 'Massachusetts'
              ,'MI' => 'Michigan'
              ,'MN' => 'Minnesota'
              ,'MS' => 'Mississippi'
              ,'MO' => 'Missouri'
              ,'MT' => 'Montana'
              ,'NE' => 'Nebraska'
              ,'NV' => 'Nevada'
              ,'NH' => 'New Hampshire'
              ,'NJ' => 'New Jersey'
              ,'NM' => 'New Mexico'
              ,'NY' => 'New York'
              ,'NC' => 'North Carolina'
              ,'ND' => 'North Dakota'
              ,'OH' => 'Ohio'
              ,'OK' => 'Oklahoma'
              ,'OR' => 'Oregon'
              ,'PA' => 'Pennsylvania'
              ,'RI' => 'Rhode Island'
              ,'SC' => 'South Carolina'
              ,'SD' => 'South Dakota'
              ,'TN' => 'Tennessee'
              ,'TX' => 'Texas'
              ,'UT' => 'Utah'
              ,'VT' => 'Vermont'
              ,'VA' => 'Virginia'
              ,'WA' => 'Washington'
              ,'WV' => 'West Virginia'
              ,'WI' => 'Wisconsin'
              ,'WY' => 'Wyoming'
            )
          )
          ,array(
            'type' => 'text'
            ,'field' => 'user_postal_code'
            ,'label' => 'Postal Code'
            ,'columns' => 3
    		,'conditions' => array(
    			array(
    				'field' => 'user_country'
    				,'value' => 'US'
    				)
    			)
          )
        )
    
      ));
    piklist('field', array(
        'type' => 'tel'
        ,'field' => 'user_number'
        ,'label' => 'Phone Number'
      ));
     
     
     ?>

    When I select a country that is not the US, the entire group disappears instead of just the city and zip code. I think the solution that Marcus proposed would work if it had a field name, but I do not want my data serialized. I have almost the exact same code on a normal meta box and the condition works fine, but when using it on my user profile it does not work as desired.

    thanks

Viewing 14 posts - 31 through 44 (of 44 total)