Nashaat
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 |
---|---|---|---|---|---|
More than one Cred ID in callback function
Started by: Nashaat
in: Toolset Professional Support
Problem: I am using the cred_save_data hook to update the status of a post, but I am having trouble adding a conditional to restrict the callback to more than one Form ID. Solution: Check your callback syntax. You can create an array of Form IDs, then test the current Form ID against that array. You must include the $form_data parameter as an input to your callback function to access the current Form's ID. // CRED PUBLISH STATUS add_action('cred_save_data', 'Select_Post_Status_func',10,2); function Select_Post_Status_func($post_id, $form_data) { if($_REQUEST['post_status'] == ''){ //Do nothing return; } //create an array of values with all ID's of the Forms you want to check: $ids = array("101","102","103"); //Check if the current form ID is one of in the above array: if (in_array($form_data['id'], $ids) ){ $my_post['ID'] = $post_id; $my_post['post_status'] = $_REQUEST['post_status']; // Update the post into the database wp_update_post( $my_post ); } } Relevant Documentation: |
3 | 9 | 6 years, 3 months ago | ||
Copy taxonomy terms from selected post into a new post created by Forms
Started by: Nashaat
in: Toolset Professional Support
Problem: I have a Form that allows Users to create a new Post. They can select a different post in the Form. I would like to copy all the taxonomy terms applied to the selected post and apply them to the new post. Solution: add_action('cred_save_data_2187', 'duplicate_post', 10, 2); function duplicate_post($post_id, $form_data) { // get data of original post $post = get_post( $form_data['container_id'], ARRAY_A ); // update Post Status to PENDING $post['post_status'] = 'pending'; // set author as current user $author_id = get_current_user_id(); $post['post_author'] = $author_id; // update the new post with this data $post['ID'] = $post_id; $post['post_title'] = 'Copy of ' . $post['post_title']; wp_update_post( $post ); // get fields of original post $fields = get_post_custom( $form_data['container_id'] ); // update the new post with these fields foreach ($fields as $key => $values) { foreach ($values as $value) { add_post_meta($post_id, $key, $value, false); } } // update Taxonomies & Categories $original_post_id = $form_data['container_id']; $new_post_id = $post_id; $original_post = get_post($original_post_id); $taxonomies = get_object_taxonomies($original_post->post_type); // returns array of taxonomy slugs for this post type foreach ($taxonomies as $taxonomy) { $post_terms = wp_get_object_terms($original_post_id, $taxonomy, array('fields' => 'slugs')); wp_set_object_terms($new_post_id, $post_terms, $taxonomy, false); } } Relevant Documentation: |
2 | 7 | 6 years, 3 months ago | ||
Duplicate post but not Author
Started by: Nashaat in: Toolset Professional Support |
2 | 3 | 6 years, 3 months ago | ||
show User Role in the Loop of a View of Users
Started by: Nashaat
in: Toolset Professional Support
Problem: I have a View of Users, and I would like to display the role of each User in the Loop. Solution: function get_user_role_func( $atts ) { $a = shortcode_atts( array( 'userid' => '' ), $atts ); $userdata = get_user_by('ID', $a['userid']); $user_roles = $userdata->roles; $user_role = array_shift($user_roles); return $user_role; } add_shortcode( 'get_user_role', 'get_user_role_func' ); Then in your View, use the shortcode in a conditional like this: [wpv-conditional if="( '[get_user_role userid='[wpv-user field='ID']']' eq 'editor' )"] I am Editor [/wpv-conditional] [wpv-conditional if="( '[get_user_role userid='[wpv-user field='ID']']' eq 'administrator' )"] I am Admin [/wpv-conditional] Relevant Documentation: |
2 | 7 | 6 years, 3 months ago | ||
Administrators and Editors option to delete other user on the frontend
Started by: Nashaat
in: Toolset Professional Support
Problem: I would like to allow Administrators and Editors to delete Users from the front-end of the site. Solution: You can use an Edit User Form and some custom code to handle this. [cred_generic_field field='user-to-delete' type='hidden' class='' urlparam=''] { "required":0, "validate_format":0, "default":[wpv-user field="ID"], "persist":1 } [/cred_generic_field] function tssupp_delete_user( $user_id, $form_data ){ if ( 203 == $form_data['id'] ) { require_once( ABSPATH.'wp-admin/includes/user.php' ); $current_user = $_POST['user-to-delete']; wp_delete_user( $current_user ); } } add_action( 'cred_submit_complete', 'tssupp_delete_user', 10, 2 ); Relevant Documentation: |
2 | 8 | 6 years, 3 months ago | ||
Change Post Status Draft/Publish of Product on the frontend
Started by: Nashaat in: Toolset Professional Support |
2 | 12 | 6 years, 3 months ago | ||
Duplicate WooCommerce Product on Frontend with Cred
Started by: Nashaat in: Toolset Professional Support |
2 | 10 | 6 years, 3 months ago | ||
Filter by WooCommerce Post Status
Started by: Nashaat in: Toolset Professional Support |
2 | 16 | 6 years, 4 months ago | ||
Filter by stock number
Started by: Nashaat
in: Toolset Professional Support
Problem: I am trying to find out if its possible to filter by woocommerce stock number? Solution: The woocommerce SKU field is a hidden field using filed slug "_sku", you can enable it in Views UI: Then you will be able to add filter on "_sku" field in view within Views UI Relevant Documentation: |
2 | 4 | 6 years, 4 months ago | ||
adding custom class to wpv-sort-orderby not working
Started by: Nashaat in: Toolset Professional Support |
2 | 4 | 6 years, 4 months ago | ||
Prosuct submitted with Cred now filtering price till product updated in backend
Started by: Nashaat
in: Toolset Professional Support
Problem: Solution: You can find proposed solution, in this case, with the following reply: Relevant Documentation: |
2 | 9 | 6 years, 4 months ago | ||
Product Category Conditional Output for Group fields in Toolset Form (cred)
Started by: Nashaat in: Toolset Professional Support |
2 | 6 | 6 years, 4 months ago | ||
Dropdwon list from Tags
Started by: Nashaat in: Toolset Professional Support |
2 | 7 | 6 years, 4 months ago | ||
Toolset Plugins slow down Website
Started by: Nashaat in: Toolset Professional Support |
2 | 7 | 6 years, 4 months ago | ||
Calculate Woo Fields
Started by: Nashaat in: Toolset Professional Support |
3 | 12 | 6 years, 4 months ago |