• grahamtree

    (@grahamtree)


    I have used this plug in to allow the users to upload a photo to my website and store it in the media library. How do I set the caption to the user field they entered please?

    The application is for a sports club and the photo they upload is the team sheet so players know who it playing without visiting the club house.

    Many thanks all.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author nickboss

    (@nickboss)

    Hi, it can be done with a plugin hook, however you need the Pro version in order to create the hook.

    Best Regards

    Nickolas

    Thread Starter grahamtree

    (@grahamtree)

    thank you Nick,

    that’s good to hear it can be done. I’m more than happy to purchase the Pro version, it’s a useful plug-in.

    Would you show me how it is done with some sample code and where to place it, assuming I have one additional user field for the user to enter the details?

    Plugin Author nickboss

    (@nickboss)

    Supposing that the caption is entered in the second user field, here is the hook code:

    if ( isset($GLOBALS["WFU_GLOBALS"]["WFU_DEBUG"]) ) $GLOBALS["WFU_GLOBALS"]["WFU_DEBUG"][3] = "ON";
    if (!function_exists('wfu_debug_wfu_process_media_insert_function_handler')) {
        function wfu_debug_wfu_process_media_insert_function_handler($res, $file_path, $userdata_fields, $page_id) {
            $attach_id = $res["output"];
            if ( $attach_id ) {
                $caption = ( isset($userdata_fields[1]) ? $userdata_fields[1]["value"] : "" );
                $args = array( 'ID' => $attach_id, 'post_excerpt' => $caption );
                wp_update_post( $args );
            }
            $res["result"] = 'R';
            return $res;
        }
        add_filter('wfu_debug-wfu_process_media_insert', 'wfu_debug_wfu_process_media_insert_function_handler', 10, 4);
        $GLOBALS['wfu_debug_end-wfu_process_media_insert'] = "1";
    }

    You need to put it in Hooks tab in plugin’s Dashboard area.

    You can also put it in functions.php file of your theme. However the hook will be lost when you update the theme.

    Nickolas

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Save a caption’ is closed to new replies.