Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • in reply to: Hide submit button based upon form #41059
    esmroscesmrosc
    Participant

    #job-sheet-featured-aspects .rwmb-form-submit .rwmb-button {
    display: none;
    }

    I added the # and it worked - thank you so much - I had been going crazy over this!

    in reply to: Hide submit button based upon form #41048
    esmroscesmrosc
    Participant

    I am also trying this code that I have been shared to aid me but it is not working

    <?php

    add_action( 'rwmb_frontend_before_submit_button', 'xxx_disable_metabox') ;

    function xxx_disable_metabox( $config ) {

    if( 'job-sheet-featured-aspects' === $config['id'] ) {

    $selector = sprintf( '.%s.rwmb-field.rwmb-button-wrapper.rwmb-form-submit', $config['id'] );
    $style = '<style>';
    $style .= $selector . '{ display: none; }';
    $style .= '</style>';

    }

    return $style;

    };

    in reply to: Hide submit button based upon form #41045
    esmroscesmrosc
    Participant

    So I am correctly targeting the form, but the submit button is still not targeted? Is there a way to target the submit button of an individual form?

    like

    <style>
    .job-sheet-featured-aspects.rwmb-field.rwmb-button-wrapper.rwmb-form-submit {
    display: none;
    }
    </style>

    in reply to: Event calendar with recurring events #39309
    esmroscesmrosc
    Participant

    following as well, sounds very useful.

    esmroscesmrosc
    Participant

    thank you so much, so i have done as you have suggested and it creates the relationship correctly. the final code i used is below;

    <?php 
    
    add_action( 'save_post', 'update_client_equipment_relationship_from_client_post_id' );
    
    function update_client_equipment_relationship_from_client_post_id ( $post_id){
    
    	//get related id from csv import of related client post id
    	$related_client_id_value = $_POST['wpcf_related_client_post_id_read_only'];                         
           
            MB_Relationships_API::add( $related_client_id_value , $post_id , 'clients-and-equipment-relationship' , $order_from = 1, $order_to = 1  );
    }

    the custom field 'wpcf_related_client_post_id_read_only' will be set in advance via csv import. i then plan to use a google web bot to manually/automatically update all the posts for me to set the relationship properly in the custom table. I will then disable the code snippet as it is only to set up the relationships in the first instance, after that it should all be done live on the site, via front end submissions. Out of interest, is/was this a crazy way of achieving this?

    esmroscesmrosc
    Participant

    If you get it working can you let me know? I might have to do this for real soon. Good luck.

    esmroscesmrosc
    Participant

    Hi, I think a work around that i considered and from memory it did work was to set the relationship id via a post select, and then when the post is saved / updated the post ID from the post select is used to set the relationship that is saved in the custom table.

    I was then considering using a google webscraper bot to automatically go through and click to update the CPT's one by one to update the relationship.

    I suppose the caveat is that you would need to know the ID of the related post and set this in the CSV file prior to uploading, which is a bit of a manual task. But hopefully it would only have to be done once, and everything else would then be done on the new site with the relationships in the custom tables.

    function update_client_equipment_relationship_from_client_post_id( $post_id ) {
    {

    //this was a post select field, but it could just be a text box with the ID set by the CSV upload?
    $client_company_to_attach_equipment_to = get_post_meta( $post_id, 'client_company_to_attach_equipment_to', true );

    //the relationship in the custom table is then updated using the value from the field, this code wording might be wrong, so you would need to check it carefully for your own use
    MB_Relationships_API::add( $client_company_to_attach_equipment_to, $post_id, 'clients-and-equipment', $order_from = 1, );
    }
    }
    add_action( 'rwmb_equipment-details_after_save_post', 'update_client_equipment_relationship_from_client_post_id' );

    esmroscesmrosc
    Participant

    I have recently come back to this again and I am using the following code to use the values from two custom fields and the title of the related post to populate the title of the new post. This works in conjunction with automatically linking the the related post on submission of the form via another snippet. So that when the form is first submitted, the relation is set due the post that the form was submitted on and the values and the relationship create the title.

    So the good news is that when the form is first submitted, everything works as expected, and when in the wordpress admin post edit screen everything works as expected, with any changes made to the post reflected in the title.

    The problem comes if you use the frontend form to try and update/edit the details of the post on the front end, the edited custom field values are added at the front of the existing title. Then if the post is updated via the admin panel, everything works as expected again, and the title goes back to what it should be. I am not sure quite what causes this but hopefully someone might spot my obvious mistake.

    Hopefully the code is of use to somebody else as it stands, it is only not working if using the frontend form to edit the post.

    <?php
    
    add_action( 'rwmb_equipment-details_after_save_post', 'update_equipment_post_title');
    
    function update_equipment_post_title( $post_id ) 
    
    {// Get the vl number
        $equipmentvl = rwmb_meta( 'equipment_vl_number', '', $post_id );
    
     // Get the serial number
        $equipmentserial = rwmb_meta( 'equipment_serial_number', '', $post_id );
    	
     // Get the relation object ID via the key {$relationship_id}_from or {$relationship_id}_to
        $related_title_1 = get_the_title( $_POST['clients-and-equipment_from'] );
    	
    	$post_slug = sanitize_title_with_dashes ($my_post,'','save');
    			$post_slugsan = sanitize_title($post_slug);
        
     // Prepare update post
        $my_post = array(
            'ID' => $post_id,
            'post_title' => $equipmentvl . ' ' . $equipmentserial . '-' . $related_title_1,
    		'post_name' => $post_slugsan,
    		
        );
    
        wp_update_post ( $my_post ) ;}
    esmroscesmrosc
    Participant

    Thank you so much, I have been away from my computer for a few weeks but this was perfect. I had to remove the [0] from your code as it seemed to load in 'Hello World' but now it appears to work. Thank you again. The edited code line is below.

    // Get the relation object ID via the key {$relationship_id}_from or {$relationship_id}_to
    $related_title_1 = get_the_title( $_POST['clients-and-equipment_from'] );

    esmroscesmrosc
    Participant

    Thanks for your suggestion, I did not know about this so will look into it. I am already using rwmb_frontend_after_process to save some information into some custom fields so this could work well.

    in reply to: Create/Update CPT title from relationship title #33617
    esmroscesmrosc
    Participant

    Please can you give an example of the code to achieve this? It is exactly what I need to do but I cannot work it out from your answer above.

    esmroscesmrosc
    Participant

    Thanks, I have read that topic before so I am sorry for starting a new one, but would you be able to expand upon the code with an example of how to achieve it?

    esmroscesmrosc
    Participant

    Thank you for confirming and for asking for the possibility to be explored. It would be very helpful for the future.

    in reply to: Import data is possible with custom table extensión? #33576
    esmroscesmrosc
    Participant

    I would also love to know if there was any further progress on this as an integration with WP AllImport? All the basic custom fields seem fine, I really need the relationships to be able to be imported/exported.

    in reply to: Prepopulate relationship field with current post id #33573
    esmroscesmrosc
    Participant

    So, I came back to this today and with a bit more digging around I got it to work, just had to add this condition to the snippet -

    if ( is_singular( 'client' ) )

    full snippet below if useful for anyone else. I know its super simple like i thought it should be, but I am very happy with it working!

    //Add a connection to the post itself after submitting the post
    add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
    
    if ( is_singular( 'client' ) ){
    
    MB_Relationships_API::add( get_queried_object_id(), $post_id, 'clients-and-equipment', $order_from = 1, $order_to = 1 );}
    
    }, 10, 2 );
Viewing 15 posts - 1 through 15 (of 16 total)