• Hi Tareq I need help, regarding the custom fields I’ve solved the problem by changing the prefix of the custom field.
    But now I want to integrate custom taxonomies, my custom taxonomies already are created from the function.php of templae and are read from the same template and print. How can I do to insert a field input for custom taxonomies in-form? I can get a good donation or if you want you tell me how much it costs! thank you!

Viewing 5 replies - 31 through 35 (of 35 total)
  • @chadamas

    Thanks that’s another problem solved, easy when you know how. I just
    couldn’t get my head round it.

    I tried modifying the code for my custom taxonomy of “country”, and although it showed the dropdown box, it wouldn’t save the data. What did I do wrong? I’m not using custom post types.

    function wpufe_country( $post_type, $post = null) {
        ?>
    
        <label for="country">
                Media <span class="required">*</span>
        </label>
    
        <?php 
    
        // Add security nonce check
        wp_nonce_field( __FILE__, 'nonce-country' );
    
        // Get all media taxonomy terms
        $medias = get_terms('country', 'hide_empty=0'); //$medias = wp_get_object_terms( $post->ID, 'country', array('fields' => 'ids') );
    
        ?>
    
        <li>
    
        <?php
    
        // You can also use the included dropdown generator function of wordpress, but I'd prefer to code the select myself in order to avoid possible problems
        //wp_dropdown_categories('taxonomy=country&hide_empty=0&orderby=name&name=post_media&show_option_none=Select media&selected='.$medias[0]);
    
        ?> 
    
        <select name='post_media' id='post_media' class="requiredField">
        <option value='' <?php if (!count($medias)) echo "selected='selected'";?>>Select a Country</option>
        <?php
    	foreach ($medias as $media) {
                    $selected = (has_term($media->slug, 'country', $post->ID)) ? ' selected="selected" ' : '';
    		echo "<option value='" . $media->name . "' " . $selected . ">" . $media->name . "</option>\n";
    	}
        ?>
        </select>    
    
        </li>
        <?php
    }
    
    /**
     * The following action adds a form section
     * below the description field of WP User Frontend
     */
    
    add_action( 'wpuf_add_post_form_after_description', 'wpufe_country', 10, 2 );
    
    /**
     * Validate existence of the media after anecdote creation/edit
     * If the select is empty, it returns an error message
     *
     * @uses 'wpuf_add_post_validation' filter
     *
     * @param array $errors errors array
     * @return array errors array
     */
    
    function wpufe_media_validation( $errors ) {
        if( $_POST['post_media'] == '' ) {
            $errors[] = 'Please select a country';
        }
    
        return $errors;
    }
    add_filter( 'wpuf_add_post_validation', 'wpufe_media_validation' );
    add_filter( 'wpuf_edit_post_validation', 'wpufe_media_validation' );
    
    /**
     * Input the media data after submitting
     */
    
    if (function_exists('wpufe_country')) {
        add_action('save_post', 'save_country_data');
    }
    
    /**
     * Save the media taxonomy data
     */
    
    function save_country_data($post_id) {
    // verify this came from our screen and with proper authorization.
    
     	if ( !wp_verify_nonce( $_POST['nonce-country'], __FILE__ )) {
        	return $post_id;
      	}
    
      	// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything
            // maybe you'll find this unnecessary since there is no possible autosave in the frontend
      	if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
        	return $post_id;
    
      	// Check permissions
      	if ( 'anecdote' == $_POST['post_type'] ) {
        	if ( !current_user_can( 'edit_page', $post_id ) )
                return $post_id;
      	} else {
                if ( !current_user_can( 'edit_post', $post_id ) )
                return $post_id;
      	}
    
      	// OK, we're authenticated: we need to find and save the data
    
            $post = get_post($post_id);
    	if ($post->post_type == 'country') {
               $media = $_POST['post_media'];
    	   wp_set_object_terms( $post_id, $media, 'country' );
            }
    }

    hii J Grandin

    your code very helpd me. but i want to make anther drop down to anther post type with difrent taxomony. withe IF the post type =x then get drop down 1 , else get drop sown tow.

    sory for my english and thanks

    oded

    Changed over to the 1.1.0-fork-2RRR-4.4 alpha version by professor99 and my taxonomy dropdowns no longer appear on the add and edit forms, has anyone else encountered this problem if so could you please give me some advice as I am stumped.

    I found that the action hook is called differently in the forked version. In the examples on this thread the action hook is added like this

    add_action( 'wpuf_add_post_form_after_description', 'wpufe_taxonomy_type', 10, 2 );

    and called in the original add and edit files using the following code:

    do_action( 'wpuf_add_post_form_after_description', $post_type );

    in the forked version this code is used to call the action hook:

    do_action( 'wpuf_post_form', 'add', 'after_description', $post_type, $post );

    is there any way I can modify the code in my functions.php so it shows in the add and edit pages without editing the plugin code.

    Cheers

    Tkhan

Viewing 5 replies - 31 through 35 (of 35 total)
  • The topic ‘[Plugin: WP User Frontend] Custom Taxonomies’ is closed to new replies.