Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter newbars

    (@newbars)

    Hi @wpdatatables thanks for the answer, it was that i was calling the wp-blog-header.php wrongly

    Now my question is if is posible to get the data making a foreach loop or this method only works with the classic wp_query, do you have any example of using a for each loop?

    • This reply was modified 3 years, 3 months ago by newbars.
    Thread Starter newbars

    (@newbars)

    @missveronicatv I have activated that too but for project requirements is necessary that if a user change their password from the Password Reset Page they get a notification on their email, maybe is a bug from the plugin? or i just have to code a function to be send that email?

    Thread Starter newbars

    (@newbars)

    hi @missveronicatv thanks for the answer, im using that plugin for sending my emails using amazon services and the problem is there, when i search in the log of wp mail smtp i saw that the admil email is sending but the user email isnt

    Thread Starter newbars

    (@newbars)

    Hello, yes the photos are making into the media library

    The post making to _studiare_portafolio meta data. is:

    <input type="file" name="trabajos_empresa[]" id="trabajos_empresa" aria-required="true" multiple="multiple">

    I have other fields created with cmb2 and all save the data fine except this one, in this form i save too the featured image so i don’t know if that is making confict, here i show you the complete code for save the post

    // Add the content of the form to $post as an array
        $post = array(
            'post_author'    => get_current_user_id(),
            'post_title'    => $_POST['nombre_empresa'],
            'post_content'  => $_POST['descripcion_empresa'],
            'post_status'   => 'pending',   // Could be: publish
            'post_type' 	=> 'empresa' // Could be: 'page' or your CPT
        );
    
    	$post_id = wp_insert_post($post);
    
        wp_set_post_terms($post_id, array($_POST['cat_servicios']), 'categorias_servicios', true);
        wp_set_post_terms($post_id, array($_POST['no_empleados']), 'no_de_empleados', true);
        wp_set_post_terms($post_id, array($_POST['tempresa']), 'tamano_empleados_empresa', true);
        wp_set_post_terms($post_id, array($_POST['cl_empresa']), 'clientes_empresa', true);
        wp_set_post_terms($post_id, array($_POST['dep_empresa']), 'departamentos', true);
        wp_set_post_terms($post_id, array($_POST['mun_empresa']), 'municipios', true); 
      
        //Informacion adicional de la empresa
        update_post_meta($post_id, '_studiare_fundacion_empresa', $_POST['creacion_empresa']);
        update_post_meta($post_id, '_studiare_nit_empresa', $_POST['nit_empresa']);
    	update_post_meta($post_id, '_studiare_pweb_empresa', $_POST['pagina_empresa']);
        update_post_meta($post_id, '_studiare_certificaciones_empresa', $_POST['certificaciones_empresa']);
        update_post_meta($post_id, '_studiare_areas_negocio_empresa', $_POST['areas_empresa']);
        update_post_meta($post_id, '_studiare_productos_empresa', $_POST['pd_empresa']);
        update_post_meta($post_id, '_studiare_calle_empresa', $_POST['direccion_empresa']);
        update_post_meta($post_id, '_studiare_contacto_empresa', $_POST['nombre_contacto']);
        update_post_meta($post_id, '_studiare_correo_empresa1', $_POST['correo_elec1']);
        update_post_meta($post_id, '_studiare_correo_empresa2', $_POST['correo_elec2']);
        update_post_meta($post_id, '_studiare_tlf_empresa1', $_POST['nro_tlf1']);
        update_post_meta($post_id, '_studiare_tlf_empresa2', $_POST['nro_tlf2']); 
    
    	// For Featured Image
    	if( !function_exists('wp_generate_attachment_metadata')){
    		require_once(ABSPATH . "wp-admin" . '/includes/image.php');
    		require_once(ABSPATH . "wp-admin" . '/includes/file.php');
    		require_once(ABSPATH . "wp-admin" . '/includes/media.php');
    	}
        
        if ( isset( $_FILES['post_image'] ) ) {
            $attach_id = media_handle_upload( 'post_image', $post_id );
        
            if ( $attach_id && ! is_wp_error( $attach_id ) ) {
                set_post_thumbnail( $post_id, $attach_id );
            }
        }
    
        $otherfiles = $_FILES['trabajos_empresa'];
        if ( isset( $_FILES['trabajos_empresa'] ) ) {
            foreach ( $otherfiles['name'] as $key => $value ) {
                if ( $otherfiles['name'][ $key ] ) {
                    $file = array(
                        'name' => $otherfiles['name'][ $key ],
                        'type' => $otherfiles['type'][ $key ],
                        'tmp_name' => $otherfiles['tmp_name'][ $key ],
                        'error' => $otherfiles['error'][ $key ],
                        'size' => $otherfiles['size'][ $key ],
                    );
                    $_FILES['trabajos_empresa'] = $file;
                    if ( is_wp_error( $attachment_id ) ) {
                        echo $attachment_id->get_error_message();
                    } else {
                        $attachment_id = media_handle_upload( 'trabajos_empresa', $post_id );
                        update_post_meta( $post_id,'_studiare_portafolio', $attachment_id );
                    }
                }
            }  
        }else{
            echo 'Agrega las fotos ';
        }
    Thread Starter newbars

    (@newbars)

    So i just make a for each in the select to display my options create with

    'options'          => array(
    	'standard' => __( 'Option One', 'cmb2' ),
    	'custom'   => __( 'Option Two', 'cmb2' ),
    	'none'     => __( 'Option Three', 'cmb2' ),
    ),

    And the using the update_post_meta fuctions i can save up the value

    For example these are my options in the radio field

    $empresas_metaboxes->add_field( array(
            'name'    => esc_html__( 'No. de empleados', 'studiare' ),
            'id'      => 'empleados_empresa',
            'type'    => 'radio',
            'options' => array(
                '2-5' => '2-5 empleados',
                '5-10' => '5-10 empleados',
                '10-15' => '10-15 empleados',
                '20' => '+20 empleados',
            ),
        ) );

    and the select would be

    <select id="mytheme_custom_select" name="mytheme_custom_select">
        <option value="2-5">2-5 empleados</option>
        <option value="5-10">5-10 empleados.</option>
        <option value="10-15">10-15 empleados</option>
        <option value="20">20 empleados</option>
    </select>

    And in the query for save post just run update_post_meta($post_id, '_studiare_empleados_empresa', sanitize_text_field($_POST['mytheme_custom_select']));

    • This reply was modified 3 years, 6 months ago by newbars.
    Thread Starter newbars

    (@newbars)

    I try to explain better, English isn’t my first language so sorry for the mistakes

    I have a custom post type called business and created a metabox for that CPT the idea of this CPT is that my logged users can post their companies

    I want to create a front end form to my users submit the information and get save in the metabox I create

    One of the fields is a radio button called employee numbers

    I want that the options of that radio button display on the form so the users can select one and later save in that custom field

    Is this possible? If is possible how we can do that or I have to use that snippet?

    • This reply was modified 3 years, 6 months ago by newbars.
    Thread Starter newbars

    (@newbars)

    Nice, thanks for the answer i will try that example

    i got another question for you, in one of the metaboxes i had a radio field

    if i want to make a custom form not using that snippet how can i show the radio options in that form so users can select and save that option in that field?

    Thanks again!

    Thread Starter newbars

    (@newbars)

    Works wonderful, i just had to change priority from 10 to 15 and works fine

    Thanks so much for your help michael!

Viewing 8 replies - 1 through 8 (of 8 total)