Forum Replies Created
-
AuthorPosts
-
kabadabraMemberJust to update, I tried another meta box for “page” on another project now and the same issue occurs. This seems to be a bug in Piklist. If there is any solution for this already, please let me know. Thanks!! 🙂
In my example above, I’m trying to update from 22 to 36, but on save it reverts back to 22. The first time you save when it is blank it works. It’s when you trying to update after the value is saved that is doesnt work from a secondary admin user.
kabadabraMember@steve – Thanks for the quick fix/update. Updated, re-tested and Sucuri no longer reports the malware/security issue. I think it’s safe to say it’s a problem with their algorithm most likely when detecting a 500 error.
Redirect working as expected now too, thanks!!
kabadabraMemberBeing upgraded from an older version, there also seems to be a bug with saving the “301 Redirect” option. I can set it to any other page, but when “No” is selected, it does not get saved.
See: https://dl.dropboxusercontent.com/s/czb09ya1drppl7c/2016-06-27%20at%2018.28.jpg
I think this is what may be causing the blank page issue on a 404 page.
kabadabraMember@Steve – Ahh ok thank you, for now ill use the meta field to do queries against to get the relationships. Keep up the good work, piklist is awesome! 🙂
kabadabraMember@Steve – Tried a few tests now and also doesnt work. Latest post created from frontend = ID 410, but not ID gets added to the table – https://dl.dropboxusercontent.com/s/dgvvnkyw872l1v1/2016-06-08%20at%2020.28.jpg
So creating from frontend the relationships are also not working.
kabadabraMember@Steve (and hi)
I already have the following at the top of my form:
// Where to save this form piklist('field', array( 'type' => 'hidden', 'scope' => 'post', 'field' => 'post_type', 'value' => 'properties' ) );Here is an example of my property relation on a tenant. Current the tenant is set to Jon Snow for the 1 Castle Black property. See: https://dl.dropboxusercontent.com/s/g5ko68xmlovvpuu/2016-06-08%20at%2019.44.jpg
Now when I edit the property on the frontend, and I set the tenant to Daenerys, the relation still does not get updated. However it updates from the backend just fine, but as you say that’s because the admin environment knows how to deal with it. See: https://dl.dropboxusercontent.com/s/apx87aorwe57vc9/2016-06-08%20at%2019.46.jpg
If it helps, I attached the full form php file. I can’t get the relation to update from the frontend 🙁
<?php /* Title: Properties Method: post Message: Property Saved. Logged in: true */ // Get page edit value $getEdit = $_GET['_post']; $postID = $getEdit['ID']; // Where to save this form piklist('field', array( 'type' => 'hidden', 'scope' => 'post', 'field' => 'post_type', 'value' => 'properties' ) ); // post_status piklist( 'field', array( 'scope' => 'post', 'type' => 'hidden', 'field' => 'post_status', 'value' => 'publish' ) ); if($postID == '') { // Property Owner piklist( 'field', array( 'scope' => 'post_meta', 'type' => 'hidden', 'field' => '__property_owner', 'value' => get_current_user_id() ) ); } /*************************/ // Address 1 piklist( 'field', array( 'type' => 'text', 'scope' => 'post_meta', 'field' => 'property_address_1', 'label' => 'Address 1', 'attributes' => array( 'class' => 'regular-text' ), 'required' => true ) ); // Address 2 piklist( 'field', array( 'type' => 'text', 'scope' => 'post_meta', 'field' => 'property_address_2', 'label' => 'Address 2', 'attributes' => array( 'class' => 'regular-text' ), 'required' => false ) ); // City / Town piklist( 'field', array( 'type' => 'text', 'scope' => 'post_meta', 'field' => 'property_city', 'label' => 'City / Town', 'attributes' => array( 'class' => 'regular-text' ), 'required' => true ) ); // Postal Code piklist( 'field', array( 'type' => 'text', 'scope' => 'post_meta', 'field' => 'property_postcode', 'label' => 'Post Code', 'attributes' => array( 'class' => 'regular-text' ), 'required' => true ) ); // Tenants // Relational Field if ( is_admin() ) { $meta_query = array( 'post_type' => 'tenants', 'numberposts' => - 1 ); } else { $meta_query = array( 'post_type' => 'tenants', 'numberposts' => - 1, 'meta_query' => array( array( 'key' => '__tenant_landlord', 'value' => get_current_user_id(), 'compare' => '=', ), ), ); } piklist( 'field', array( 'scope' => 'post_meta', 'type' => 'select', 'field' => '_' . piklist::$prefix . 'property_tenant', 'label' => 'Tenant', 'choices' => piklist( get_posts( $meta_query ), array( 'ID', 'tenant_firstname' ) ), 'relate' => array( 'scope' => 'post' ) ) ); /*************************/ // Submit if($postID == '') { $submit_label = 'Create My Property'; } else { $submit_label = 'Update My Property'; } piklist( 'field', array( 'type' => 'submit', 'field' => 'submit', 'value' => $submit_label, 'attributes' => array( 'class' => 'submit-button', //'disabled' => 'disabled' ) ) );
kabadabraMemberSetting the scope to post didn’t work. It doesn’t save the field “__property_tenant” as meta. When set as post_meta, the meta saves at least but the relationship is unchanged and still uses the previous item that was set as the relation.
kabadabraMemberOn the frontend form, the relation “saving” doesnt seem to work. I added a scope with post_meta as the value so that it gets saved. The relation however is not working. It only works when I save it from the backend. Is there anything special to add for relationships on a frontend form?
piklist( 'field', array( 'scope' => 'post_meta', 'type' => 'select', 'field' => '_' . piklist::$prefix . 'property_tenant', 'label' => 'Tenant', 'choices' => piklist( get_posts( array( 'post_type' => 'tenants', 'numberposts' => -1, 'meta_query' => array( array( 'key' => '__tenant_landlord', 'value' => get_current_user_id(), 'compare' => '=', ), ), ) ), array('ID', 'tenant_firstname') ), 'relate' => array( 'scope' => 'post' ) ) );
kabadabraMemberThanks Jason, really a big help! Will adjust my code and give it a try.
kabadabraMemberAhh ok cool, got it now, thanks!
So then instead of __property_owner for the ‘field’, I should be using something like __relate_tenants, __relate_properties etc? Or will this always still be __relate_post?
kabadabraMemberHi Jason,
Here is the example of my three relationships
// Agents // Relational Field piklist( 'field', array( 'type' => 'select', 'field' => '_' . piklist::$prefix . 'property_owner', 'label' => 'Owner', 'choices' => piklist( get_users( array( 'role' => '' // Todo: Set to agent ) ), array('ID', 'display_name') ), 'relate' => array( 'scope' => 'users' ) ) ); // Tenants // Relational Field piklist( 'field', array( 'type' => 'select', 'field' => '_' . piklist::$prefix . 'property_tenant', 'label' => 'Tenant', 'choices' => piklist( get_posts( array( 'post_type' => 'tenants', 'numberposts' => -1, 'meta_query' => array( array( 'key' => '__tenant_landlord', 'value' => get_current_user_id(), 'compare' => '=', ), ), ) ), array('ID', 'tenant_firstname') ), 'relate' => array( 'scope' => 'tenants' ) ) ); // Agents // Relational Field piklist( 'field', array( 'type' => 'select', 'field' => '_' . piklist::$prefix . 'property_agent', 'label' => 'Agent', 'choices' => piklist( get_users( array( 'role' => '' // Todo: Set to agent ) ), array('ID', 'display_name') ), 'relate' => array( 'scope' => 'users' ) ) );When I try run the following code I don’t get any results:
$related_properties = get_posts( array( 'post_type' => 'properties', // Set post type you are relating to. 'posts_per_page' => - 1, 'post_belongs' => $postID, 'post_status' => 'publish', 'suppress_filters' => false, // This must be set to false ));So for now I’m pretty much running the following to get it working:
$related_properties = get_posts( array( 'post_type' => 'properties', // Set post type you are relating to. 'posts_per_page' => - 1, 'post_status' => 'publish', 'suppress_filters' => true, // This must be set to false 'meta_key' => '__property_tenant', 'meta_value' => $postID ) );Not sure if I’m doing something wrong or misunderstanding the relationship concept. Appreciate the assistance 🙂
December 17, 2015 at 1:42 am in reply to: post meta group of fields – always duplicating content #5363
kabadabraMemberTry upgrading to 0.9.9.7, issue is fixed in the more recent builds.
Link: http://piklist.com/trunk
Screenshot of working example: https://dl.dropboxusercontent.com/s/v6yat96lyvu7ty8/2015-12-17%20at%2007.44.jpg
kabadabraMemberPerfect, this makes sense now. Thanks Steve! LEGEND!
kabadabraMemberHi Steve, I think you misunderstood what I’m trying to do.
I have a select list like the following: https://dl.dropboxusercontent.com/s/cubjkioi629s2h3/2015-12-14%20at%2021.33.jpg
I want to make certain <options> disabled but not sure how you set an attribute per choice? The code that you’ve given above would make a whole field or select disabled.
I managed to build a workaround as per in my screenshot for getting custom taxonomies saved from the front end. But it’s a long way around to something potentially simple.
Appreciate your feedback and thoughts as always, thank you.
kabadabraMemberI might not understand the above correctly, but I’m assuming you want the post to be set to published when created?
If so, add the following to your code:
// post_status piklist( 'field', array( 'scope' => 'post', 'type' => 'hidden', 'field' => 'post_status', 'value' => 'publish' ) ); -
AuthorPosts