Support » Plugin: NextGEN Custom Fields » Auto-add custom field to new galleries

Viewing 2 replies - 1 through 2 (of 2 total)
  • vano1979

    (@vano1979)

    Hi!
    I just got the same problem, debuging I found the next solution in ngg-custom-fields.php
    Change the whole function nggcf_add_new_gallery for this:

    // IVAN MUĂ‘OZ ORTEGA
    		// 14/04/2016
    		// http://ivanmunozortega.com
    		// PROBLEM CREATING GALLERY, $_POST["cont"] doesn't seem to work
    		function nggcf_add_new_gallery($gid) {
    			global $wpdb, $nggcf_image_cols;
    			$fields = nggcf_get_field_list(NGGCF_IMAGES);
    
    			// if($fields = stripslashes_deep($_POST["conf"]["nggcf_fields"])) {
    			if ($fields) {
    				foreach ((array)$fields as $key=>$val) {
    					$qry = "INSERT INTO ".$wpdb->prefix."nggcf_fields_link (<code>id</code>, <code>field_id</code>, <code>gid</code>)
    					SELECT * FROM (SELECT 'null', '".esc_sql($val->id)."', '".esc_sql($gid)."') AS tmp
    					WHERE NOT EXISTS (
    						SELECT id FROM ".$wpdb->prefix."nggcf_fields_link WHERE field_id = '".esc_sql($val->id)."' and gid = '".esc_sql($gid)."'
    					) LIMIT 1;";
    
    					// $qry = "INSERT INTO ".$wpdb->prefix."nggcf_fields_link (<code>id</code>, <code>field_id</code>, <code>gid</code>) VALUES(null, '".esc_sql($val->id)."', '".esc_sql($gid)."')";
    					$wpdb->query($qry);
    				}
    			}
    		}

    Ivan.

    Possible to get this in a release?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Auto-add custom field to new galleries’ is closed to new replies.