Team DNK
Support threads created in the last 30 days: 0
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Fields and Views – Modify Shortcode Output
Started by: Team DNK
in: Toolset Professional Support
Problem: We are needing a way to extend/modify the existing field and view shortcodes. Solution: Toolset View/Types shortcodes are also registered with WP function add_shortcode(), so you can use WP built-in filter hook do_shortcode_tag to apply your custom codes Relevant Documentation: https://developer.wordpress.org/reference/hooks/do_shortcode_tag/ |
2 | 3 | 3 years, 9 months ago | ||
ToolSet Settings Custom Code – How To Define Name In Code.
Started by: Team DNK in: Toolset Professional Support |
2 | 3 | 5 years ago | ||
ToolSet Settings Custom Code Missing Description Field
Started by: Team DNK
in: Toolset Professional Support
Problem: Solution: |
2 | 3 | 5 years ago | ||
Favorite Posts By Logged In User (Add To / Remove not working properly)
1
2
Started by: Team DNK
in: Toolset Professional Support
Problem: I would like Users to be able to choose certain posts as favorites. They should also be able to remove them from favorites. Solution: Create a CRED form that allows you to modify the posts that can be favorited. Remove all the content from the CRED form and replace it with the following code: [credform class='cred-form cred-keep-original'] [wpv-conditional if="( [toolset_is_favorite id='[wpv-post-id]'] eq '1' )"] [cred_generic_field field='remove-favorite' type='hidden' class=''] { "required":0, "validate_format":0, "default":"1" } [/cred_generic_field] [/wpv-conditional] [cred_field field='form_submit' value='Favorite' urlparam='' class='x-btn x-btn-global mam'] [/credform] Add the following JavaScript to your CRED form's JS panel: jQuery(window).bind("load", function() { jQuery( "form[id^='cred_form_368']").find("input[type='submit']").val(jQuery( "input[name='remove-favorite']").length ? "Remove from Favorites" : "Add to Favorites"); } ) This code will toggle between showing "Add to Favorites" and "Remove from Favorites" as the button name. Add the following PHP to your child theme's functions.php file: add_action('cred_save_data_368', 'sda_user_favorites',10,2); function sda_user_favorites($post_id, $form_data) { if( isset($_REQUEST['remove-favorite']) ) { delete_post_meta($post_id, 'wpcf-favorites', get_current_user_id()); } else { add_post_meta($post_id, 'wpcf-favorites', get_current_user_id(), false); } } /* Favorites shotcode for use as a conditional */ add_shortcode( 'toolset_is_favorite', 'toolset_is_favorite_func'); function toolset_is_favorite_func($atts) { global $wpdb; $post_id = $atts['id']; $user_id = get_current_user_id(); $favorites = $wpdb->get_results( "SELECT * FROM wp_postmeta WHERE meta_key = 'wpcf-favorites' AND post_id = $post_id AND meta_value = $user_id LIMIT 1"); return sizeof($favorites) ? 1 : 0; } Be sure to add the toolset_is_favorite shortcode in Toolset > Settings > Frontend content > 3rd party shortcode arguments. Place the CRED form in a View of posts, or in a Content Template for these posts. Relevant Documentation: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data |
3 | 19 | 6 years, 3 months ago | ||
Control View’s output with Access
1
2
3
Started by: Team DNK
in: Toolset Professional Support
Problem: Solution: |
5 | 47 | 6 years, 4 months ago | ||
Access Not Directing Restricted User to 404 Page
1
2
3
Started by: Team DNK in: Toolset Professional Support |
3 | 40 | 6 years, 10 months ago | ||
Views Query Filter based on Access Post Group
1
2
Started by: Team DNK in: Toolset Professional Support |
4 | 24 | 6 years, 11 months ago | ||
Add Leading Zeros To Number Field
Started by: Team DNK
in: Toolset Professional Support
Problem: I would like to display a number from a custom field in my post with at least 3 digits. If necessary, I would like to pad the number with leading zeros. Solution: Display the custom field using a custom shortcode. This shortcode will append leading zeros if necessary to the display without affecting the value stored in the database. This is helpful because it can be used in various places on the site and it does not break numeric sorting, calculations, or comparisons. /* --------------------------------------------- */ // CUSTOM THREE DIGIT SHORTCODE add_shortcode( 'pad_three_digits', 'my_pad_three_digits_func'); function my_pad_three_digits_func($atts) { $num = $atts['num']; return str_pad($num, 3, '0', STR_PAD_LEFT); } [pad_three_digits num="1"] // 001 [pad_three_digits num="10"] // 010 [pad_three_digits num="100"] // 100 [pad_three_digits num="1000"] // 1000 [pad_three_digits num="[types field='project-number' format='FIELD_VALUE'][/types]"] // outputs a custom field number padded if necessary Relevant Documentation: https://codex.wordpress.org/Shortcode_API |
2 | 7 | 6 years, 12 months ago | ||
Only Want Auto Numbering For New Post, Not When Editing The Post
Started by: Team DNK
in: Toolset Professional Support
Problem: I would like to include a custom field value on my Project post type that begins at zero and is incremented for each new post. When I modify an existing post, I do not want the existing auto increment value to change. Solution: /* Auto number Project posts */ add_action( 'save_post', 'auto_number', 100, 3 ); function auto_number( $post_id, $post, $update ) { if ( $post->post_status == 'publish' && $post->post_type == 'project' ) { $project_args = array( 'numberposts' => 2, 'post_type' => 'project', 'orderby' => 'post_date', 'order' => 'DESC' ); $projects = get_posts( $project_args ); // don't update existing auto-numbering $this_id = get_post_meta( $projects[0]->ID, 'wpcf-project-number', true); if ( $this_id ) { return; } $last_id = get_post_meta( $projects[1]->ID, 'wpcf-project-number', true); if ( !$last_id ) { $last_id = 0; } $last_id++; update_post_meta( $post_id, 'wpcf-project-number', $last_id ); } } |
2 | 7 | 6 years, 12 months ago | ||
Restrict Access To Specific Team Members Only
1
2
Started by: Team DNK in: Toolset Professional Support |
3 | 25 | 7 years ago | ||
"Display Message Instead of Form" Option Displays wrong Post Title
Started by: Team DNK in: Toolset Professional Support |
2 | 6 | 7 years, 1 month ago | ||
Possible Bug With Toolset Access Advanced Mode
Started by: Team DNK in: Toolset Professional Support |
2 | 10 | 7 years, 1 month ago | ||
Dynamic Login/Logout Link With CRED Login Form And Redirects
Started by: Team DNK in: Toolset Professional Support |
2 | 6 | 7 years, 1 month ago | ||
How Can I Build a Toolset Style Login/Logout Menu
Started by: Team DNK in: Toolset Professional Support |
3 | 6 | 7 years, 1 month ago | ||
Possible Bug With Forgot Password Form
Started by: Team DNK in: Toolset Professional Support |
2 | 3 | 7 years, 1 month ago |