Forum Replies Created

Viewing 15 replies - 1 through 15 (of 70 total)
  • Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    here is a simplified version of the code which no longer works with the latest CF7 update

    
    function dynamic_select_field_values($scanned_tag, $replace) {
        global $current_user;
        $current_user = wp_get_current_user();
        $current_pilote = $current_user->user_login;
    	
    	 //$current_pilote ='plugin2024';
    
        if ($scanned_tag['name'] != 'menu_913') 
            return $scanned_tag;
    
        $rows = get_posts(
            array (
                'post_type'    => $current_pilote,
                'numberposts'  => -1,
                'orderby'      => 'title',
                'order'        => 'ASC',
            )
        );
    
        if (!$rows) 
            return $scanned_tag;
    
        foreach ($rows as $row) {
            $scanned_tag['raw_values'][] = $row->post_title;
        }
    
        $scanned_tag['values'] = $scanned_tag['raw_values'];
    
        return $scanned_tag;
    }
    add_filter('wpcf7_form_tag', 'dynamic_select_field_values', 10, 2);

    the code does not work if I use $current_pilote = $current_user->user_login;
    on the other hand if I use: $current_pilote =’plugin2024′;
    the code works.
    plugin2024 is the user login

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    Thanks!
    now I found a better code that works:

    
    // Inclure les fichiers nécessaires
    $image_url = 'https://www.bluehouse.fr/wp-content/uploads/2023/11/capture-2023-11-06-a?-08.48.01.jpg';
    
    //upload_image_to_library($image_url );
    
    function upload_image_to_library($image_url ){
    
    // Inclure les fichiers nécessaires
    require_once(ABSPATH . 'wp-includes/pluggable.php');
    require_once(ABSPATH . 'wp-admin/includes/file.php');
    require_once(ABSPATH . 'wp-admin/includes/media.php');
    require_once(ABSPATH . 'wp-admin/includes/image.php');
    
    // Utilisez la fonction media_sideload_image pour télécharger l'image depuis l'URL.
    $upload = media_sideload_image($image_url, 0);
    
    // Vérifiez si le téléchargement de l'image a réussi.
    if (!is_wp_error($upload)) {
        // L'image a été téléchargée avec succès, et $upload est un tableau contenant les informations sur l'image.
        echo 'Image uploaded successfully!';
    } else {
        // Une erreur s'est produite lors du téléchargement de l'image.
        echo 'Error uploading image: ' . $upload->get_error_message();
    }
    
    
    }
    
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    This the code I’m trying to work with:

    
    $image_url= 'https://localhost:8888/chvd//wp-content/plugins/topo-new/topo_multi_zip_2/736192002/DSC08980-1024x683-1.jpeg';
    
    media_upload($image_ur);
    
    function media_upload($image_ur){
    	
    	require_once(ABSPATH . 'wp-admin/includes/media.php');
    require_once(ABSPATH . 'wp-admin/includes/file.php');
    require_once(ABSPATH . 'wp-admin/includes/image.php');
    
    	
    // Utilisez la fonction media_sideload_image pour télécharger l'image depuis l'URL.
    $upload = media_sideload_image($image_url, 0);
    
    // Vérifiez si le téléchargement de l'image a réussi.
    if (!is_wp_error($upload)) {
        // Convertissez l'URL de l'image téléchargée en un ID d'attachement.
        $attachment_id = wp_insert_attachment(array(
            'post_mime_type' => $upload['type'],
            'post_title'     => sanitize_file_name(pathinfo($image_url, PATHINFO_FILENAME)),
            'post_content'   => '',
            'post_status'    => 'inherit'
        ), $upload['file']);
    
        // Générez les données de l'attachement.
        $attachment_data = wp_generate_attachment_metadata($attachment_id, $upload['file']);
        
        // Mettez à jour les données de l'attachement.
        wp_update_attachment_metadata($attachment_id, $attachment_data);
    
        // Insérez l'ID d'attachement dans le contenu du message/page où vous souhaitez afficher l'image.
        // Remplacez "ID_DE_VOTRE_MESSAGE" par l'ID réel de votre message ou page WordPress.
        $post_id = ID_DE_VOTRE_MESSAGE;
        set_post_thumbnail($post_id, $attachment_id);
    }
    
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    add_filter('content_save_pre', 'my_custom_content_filter');
    
    function my_custom_content_filter($content) {
        global $allowedposttags;
    
        // Ajouter votre balise à la liste des balises autorisées
        $allowedposttags['span']['contenteditable'] = true;
    
        // Utiliser wp_kses pour valider le contenu avec les nouvelles balises autorisées
        $content = wp_kses($content, $allowedposttags);
    
        return $content;
    }
    

    Very sorry for that I won’t do it again.

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    I asked chatGPT for help and he gave me that code:

    add_filter('content_save_pre', 'my_custom_content_filter'); function my_custom_content_filter($content) { global $allowedposttags; // Ajouter votre balise à la liste des balises autorisées $allowedposttags['span']['contenteditable'] = true; // Utiliser wp_kses pour valider le contenu avec les nouvelles balises autorisées $content = wp_kses($content, $allowedposttags); return $content; }

    and it works!

    • This reply was modified 1 year ago by bcworkz. Reason: code format fixed
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    I added your code at the beginning of my plugin and it doesn’t work.
    This is the line in my code:
    <strong><span contenteditable=”false”>Date du vol rando :</span></strong>’.$date.
    and this is what’s returned in the post content:
    <strong>Date du vol rando :</strong>22/11/2023

    $allowed_protoco what is this variable?

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    When running the cf7 form on this page:
    https://www.chvd.org/concours-photo-2023-voter/
    I have this console error:

    {"code":"rest_no_route","message":"Aucune route correspondante \u00e0 l\u2019URL et \u00e0 la m\u00e9thode de requ\u00eate n\u2019a \u00e9t\u00e9 trouv\u00e9e.","data":{"status":404}}
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    In the debug Tab I have this :

    {"uploader-info":{"drag_n_drop_heading_tag":"h5","drag_n_drop_text":"Glissez & d\u00e9posez","drag_n_drop_separator":"ou","drag_n_drop_browse_text":"Fouillez dans votre ordi...","drag_n_drop_border_color":"","drag_n_drop_of_counter_text":"de","drag_n_drop_delete_text":"","drag_n_drop_remove_text":""},"error-message":{"drag_n_drop_error_server_limit":"","drag_n_drop_error_failed_to_upload":"","drag_n_drop_error_files_too_large":"La photo d\u00e9passe la limite de 1Mo","drag_n_drop_error_invalid_file":"Format d'image inconnu","drag_n_drop_error_min_file":"","drag_n_drop_error_max_files":"Vous ne pouvez t\u00e9l\u00e9charger qu'une seule image par cat\u00e9gorie","drag_n_drop_error_max_upload_limit":"","drag_n_drop_error_size_limit":""},"chunks-settings":{"drag_n_drop_parallel_uploads":false,"drag_n_drop_chunks_upload":false,"drag_n_drop_chunk_size":false,"drag_n_drop_max_total_size":false},"pro-features":{"drag_n_drop_file_amend":"","drag_n_drop_file_ammend_forms":"","drag_n_drop_upload_dir":"","drag_n_drop_mail_attachment":"yes","drag_n_drop_save_to_media":"","drag_n_drop_links_attachments":"1","drag_n_drop_folder_option":"custom_folder","drag_n_drop_cf7_folder":"","drag_n_drop_custom_folder":"toto","drag_n_drop_dynamic_folder":"","drag_n_drop_zip_files":"1","drag_n_drop_delete_options":""},"image-optimization":{"drag_n_drop_image_resize":"1200X1200","drag_n_drop_image_quality":"90","drag_n_drop_show_img_preview":"1","drag_n_drop_thumbnail_display":"default","drag_n_drop_thumbnail_column":""},"other-features":{"drag_n_drop_disable_btn":"","drag_n_drop_hide_counter":"1"},"color-options":{"drag_n_drop_color_progressbar":false,"drag_n_drop_color_filename":false,"drag_n_drop_color_delete":false,"drag_n_drop_color_filesize":false},"debug":{"drag_n_drop_debug":false,"drag_n_drop_debug_email":false},"active-plugins":{"1":"advanced-cf7-db\/advanced-cf7-db.php","2":"akismet\/akismet.php","3":"bbpress\/bbpress.php","4":"black-studio-tinymce-widget\/black-studio-tinymce-widget.php","5":"bloom\/bloom.php","6":"bnfw\/bnfw.php","7":"challenge\/challenge.php","8":"contact-form-7-dynamic-text-extension\/contact-form-7-dynamic-text-extension.php","9":"contact-form-7-simple-recaptcha\/contact-form-7-simple-recaptcha.php","10":"contact-form-7\/wp-contact-form-7.php","11":"cookie-notice\/cookie-notice.php","12":"de-updraftplus-backup-exclude-image-thumbnails\/de-updraft-backup-exclude-image-thumbnails.php","13":"default-thumbnail-plus\/default-thumbnail-plus.php","14":"divi-100-article-card\/article-card.php","15":"divi-breadcrumbs-module\/divi-breadcrumbs-module.php","16":"duplicate-menu\/duplicate-menu.php","17":"flamingo\/flamingo.php","18":"font-awesome\/index.php","19":"google-calendar-events\/google-calendar-events.php","20":"google-maps-easy\/gmp.php","21":"if-menu\/if-menu.php","22":"multifile-upload-field-for-contact-form-7\/multifile-for-contact-form-7.php","23":"new-drag-and-drop-upload-cf7-pro\/drag-n-drop-upload-cf7-pro.php","24":"p3-profiler\/p3-profiler.php","25":"pagerestrict\/pagerestrict.php","26":"pdf-embedder\/pdf_embedder.php","27":"safe-svg\/safe-svg.php","28":"show-post-categories\/show-post-categories.php","29":"simple-lightbox\/main.php","30":"stops-core-theme-and-plugin-updates\/main.php","31":"sucuri-scanner\/sucuri.php","32":"tablepress-datatables-fixedcolumns\/tablepress-datatables-fixedcolumns.php","33":"tablepress\/tablepress.php","34":"tinymce-advanced\/tinymce-advanced.php","35":"topo-new\/topo-new.php","36":"updraftplus\/updraftplus.php","37":"upload-media-by-url\/uploadmediabyurl.php","38":"user-switching\/user-switching.php","39":"wp-discord-post-plus\/wp-discord-post.php","40":"wp-google-map-plugin\/wp-google-map-plugin.php","41":"wp-mailto-links\/wp-mailto-links.php","42":"wp-migrate-db\/wp-migrate-db.php","43":"wp-pagenavi\/wp-pagenavi.php","44":"wp-statistics\/wp-statistics.php","45":"wp-super-cache\/wp-cache.php"},"contact-form-version":"5.8.2","drag-n-drop-version":"2.10.3.1"}
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    This is what I get from console.log

    index.js?ver=5.7.5.1:1

    1. {code: ‘invalid_json’, message: ‘The response is not a valid JSON response.’}
      1. code: “invalid_json”
      2. message: “The response is not a valid JSON response.”
      3. Prototype: Object
        1. constructor: ? Object()
        2. hasOwnProperty: ? hasOwnProperty()
        3. isPrototypeOf: ? isPrototypeOf()
        4. propertyIsEnumerable: ? propertyIsEnumerable()
        5. toLocaleString: ? toLocaleString()
        6. toString: ? toString()
        7. valueOf: ? valueOf()
        8. __defineGetter__: ? __defineGetter__()
        9. __defineSetter__: ? __defineSetter__()
        10. __lookupGetter__: ? __lookupGetter__()
        11. __lookupSetter__: ? __lookupSetter__()
        12. __proto__: (…)
        13. get __proto__: ? __proto__()
        14. set __proto__: ? __proto__()
    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    For example, I want to make calculations from data generated by a CF7 form (therefore values contained in variables) and save the results of these calculations in the database. I therefore use the wpcf7_after_flamingo function to host the code that does these calculations and saves the results in the database. It works fine but if my code is not working correctly and I want to display a calculation result stored in a variable to check why the code is bugging using “echo $variable” it blocks the working of the form. So I’m looking for a way to display the contents of this variable without the form stopping working.

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    Hi Paul,
    thanks for your answer.
    My concern is that I need to check if variables used in wpcf7_after_flamingo function have the right value. In a regular function I can simply add an echo for this variable to check it’s value. But if I do that while using a cf7 form the process stops and I have no way to check the variable value. So is there a solution?

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    I publish posts from the WP Admin
    I’m using Divi and these plugins:
    – Monarch for social media
    – Sucuri Security – Auditing, Malware Scanner and Hardening
    – WP Super Cache
    I’ll deactivate these plugins and see what happens. But this issue doesn’t occur all the time…

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    function searchUser() {
        var user_login = jQuery('#user_login').val();
        jQuery.ajax({
            type: 'POST',
            url: plugin_ajax_object.ajax_url,
            data: {
    			dataType : 'json',
                'action': 'search_user',
                'user_login': user_login
            },
            success: function(results) {
                var output = "";
                for (var i = 0; i < results.length; i++) {
                    output += "ID utilisateur : " + results[i].ID + "<br>";
                }
                jQuery('#search-results').html(output);
            }
        });
    }

    I added dataType : ‘json’,
    console returns this :

    POST https://localhost:8888/carnet-de-vol/wp-admin/admin-ajax.php 400 (Bad Request)
    send @ jquery.min.js?ver=3.6.0:2
    ajax @ jquery.min.js?ver=3.6.0:2
    s.ajax.s.ajax @ jquery-migrate.min.js?ver=3.3.2:2
    searchUser @ jb_script.js?ver=5.9:14
    onclick @ (index):277

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    Hi Tobias,
    Since I sent you this message the problem has disappeared. I don’t know where it came from. It remains a mystery to me. So I didn’t need to add your css code. Thank you for the work you do on the plugin.

    Thread Starter jackbluehouse2019

    (@jackbluehouse2019)

    Thanks bcwokz,
    I sorted out, the right branch is:

    foreach ($obj->features as $index => $feature){
    	$city = $feature->properties->city;
    	echo "city : ".$city;
    }
Viewing 15 replies - 1 through 15 (of 70 total)