Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 8.5.17, custom field, expiration
- This topic has 5 replies, 2 voices, and was last updated 10 years, 1 month ago by
Steven Zahm.
-
AuthorPosts
-
06/21/2016 at 7:36 pm #380202
ottomek
ParticipantWe want to have a field for the Expiration Date of our members listing, members pay an annual fee to be in the directory.
What would the snippet be to create this text field that only the WP admin could change but it would be read-only/displayed with each Members Profile Directory area.
This value would be different for each member based on when they renewed their yearly dues. We would just update this in the admin area.
Thanks.
06/22/2016 at 8:58 am #380314Steven Zahm
Keymaster@ ottomek
re: What would the snippet be to create this text field that only the WP admin could change but it would be read-only/displayed with each Members Profile Directory area.
The following snippet should do the trick.
// Register the metabox and field. add_action( 'cn_metabox', 'cn_register_custom_metabox_and_date_field' ); function cn_register_custom_metabox_and_date_field() { $atts = array( 'title' => 'Expiration Date', // Change this to a name which applies to your project. 'id' => 'expiration_date_metabox', // Change this so it is unique to you project. 'context' => 'normal', 'priority' => 'core', 'fields' => array( array( 'name' => 'Date', // Change this field name to something which applies to you project. 'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name. 'id' => 'expiration_date', // Change this so it is unique to you project. Each field id MUST be unique. 'type' => 'datepicker', // This is the field type being added. ), ), ); if ( is_admin() && current_user_can( 'manage_options' ) ) cnMetaboxAPI::add( $atts ); }Hope that helps!
06/22/2016 at 2:06 pm #380358ottomek
ParticipantThanks that worked and I’m able as the WP Admin to add a date to each directory profile.
But this date is not appearing within the edit directory profile when I’m logged in as the member (who are only WP Subscribers). I’m drawing a blank on how I get this date to be displayed as read-only in each members profile admin area. Another snippet needed?
06/22/2016 at 3:57 pm #380363Steven Zahm
Keymaster@ ottomek
Hmmm… there is actually no way to do this presently. If you change the code snippet to this:
// Register the metabox and field. add_action( 'cn_metabox', 'cn_register_custom_metabox_and_date_field' ); function cn_register_custom_metabox_and_date_field() { $atts = array( 'title' => 'Expiration Date', // Change this to a name which applies to your project. 'id' => 'expiration_date_metabox', // Change this so it is unique to you project. 'context' => 'normal', 'priority' => 'core', 'fields' => array( array( 'name' => 'Date', // Change this field name to something which applies to you project. 'show_label' => TRUE, // Whether or not to display the 'name'. Changing it to false will suppress the name. 'id' => 'expiration_date', // Change this so it is unique to you project. Each field id MUST be unique. 'type' => 'datepicker', // This is the field type being added. 'readonly' => is_admin() && ! current_user_can( 'manage_options' ) ? TRUE : FALSE ), ), ); cnMetaboxAPI::add( $atts ); }And make these changes to Connections
../includes/class.metabox-api.phpfile, it will work the way you want. I’ve already made the change and it’ll included in the next update.Hope that helps!
06/27/2016 at 12:28 pm #380660ottomek
ParticipantThank you. I waited until the plugin update then just used this recent snippet you provided. Works exactly how we want
06/27/2016 at 12:46 pm #380663Steven Zahm
Keymaster@ ottomek
Great to hear! I’ll add the readonly option to the other supported fields in the next update.
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.
