Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 51 total)
  • Author
    Posts
  • AnLipAnLip
    Participant

    I'll add to avoid unnecessary questions about that, that every bit of information has already been created and associated (other language taxonomies and related CPTs), so they are available in the database.

    in reply to: 2 custom fields using same taxonomy #47133
    AnLipAnLip
    Participant

    For the moment the only workaround I have found is to change the field to a simple Select type, but then i lose the Taxonomy's possibility to have an archive for all posts that share the same "Country".

    What would be a better workaround ?

    in reply to: Set Default Term for Specific Post Submission Form #46483
    AnLipAnLip
    Participant

    I also tried with hook "rwmb_frontend_before_save_post' but the fatal error is still caused.

    in reply to: Set Default Term for Specific Post Submission Form #46482
    AnLipAnLip
    Participant

    Hi Peter, I'm trying your logic out but I get fatal errors crashing the site.

    This is my code, would it work ?

    add_action( 'rwmb_frontend_after_save_post', function( $config ) {
        // Make sure we're working on the correct form
        if ( 'actualites-gf' === $config['id'] ) {
            // Get the post ID
            $post_id = $config['post_id'];
            
            // Get the 'actualite' category ID
            $category_id = get_cat_ID('actualite');
            
            // Add the category to the post
            wp_set_post_categories( $post_id, array( $category_id ), true );
        }
    } );
    in reply to: Link problem with the URL field #45227
    AnLipAnLip
    Participant

    Hi Peter, I'd also like to report that the documentation for the URL type of custom field does not exist, at least it redirects to another custom field's doc page : on this page https://docs.metabox.io/fields/ when you click on the "URL" type of field, it takes you to the doc for the Text field element. If you manually try https://docs.metabox.io/fields/url/ it doesn't work (404).

    in reply to: Link problem with the URL field #45222
    AnLipAnLip
    Participant

    The problem is that an empty field will cause the text to pick up the current post's url.

    My setup is as follows :
    - in Bricks, there is a LOOP (set to the Field Group named "designers-gf") that is set to loop through the results for the "MB Group: Références Bibliographiques" group.
    - The "designers-gf" field group includes (amongst other fields) this "MB Group: Références Bibliographiques" that has two fields : a text field "designers_ref" for the text, and "designers_url" for the URL.
    - In Bricks builder, I set the url value to apply to the link for the text. Therefore if there is a value for the URL it should be used for the link, but if there is no value for the URL it should just remain a text without a link.

    Now the problem is that when there is no value inserted to the URL field, the text element will by default pick up the current post's url and link to it. I need this to remain unlinked if there is no value added to the URL field. I feel that this is the way it used to work, but I can't figure out how to get there.

    in reply to: How to use the value of a custom Taxonomy ? #44714
    AnLipAnLip
    Participant

    I think it would be so great if MetaBox added a feature that allows to select custom fields to create the Post title. I will copy this message to the FB group, that is where I have seen my feature request taken in account by Anh Tran (I believe he likes good ideas :-).

    in reply to: How to use the value of a custom Taxonomy ? #44713
    AnLipAnLip
    Participant

    IO figured it out on my own (thanks ChatGPT) and ended up with this function that works perfectly, some might find it useful :

    <?php
    function update_objet_post_title_with_designer_and_latest_values($post_id, $post, $update) {
        if ($post->post_type !== 'objet' || wp_is_post_revision($post_id) || !$update) {
            return;
        }
    
        $genre_terms = get_the_terms($post_id, 'genre');
        $genre = !is_wp_error($genre_terms) && !empty($genre_terms) ? $genre_terms[0]->name : '';
    
        $date_terms = get_the_terms($post_id, 'date');
        $date = !is_wp_error($date_terms) && !empty($date_terms) ? $date_terms[0]->name : '';
    
        $objet_designation = get_post_meta($post_id, 'objet_designation', true);
    
        $designer_title = '';
        $connected_designers = MB_Relationships_API::get_connected([
            'id'   => 'objet-designer',
            'from' => $post_id,
        ]);
    
        foreach ($connected_designers as $designer) {
            // Assuming the designer's name is stored in "last, first" format.
            $name_parts = explode(', ', $designer->post_title);
            if (count($name_parts) == 2) {
                $designer_title = trim($name_parts[1]) . ' ' . trim($name_parts[0]);
            } else {
                $designer_title = $designer->post_title; // Use original if not in expected format.
            }
            // Sanitize for safety while preserving accents and capital letters.
            $designer_title = wp_kses_post($designer_title);
            break;
        }
    
        $designer_part = $designer_title ? " - $designer_title" : '';
        $new_title = trim("$genre \"$objet_designation\"$designer_part - $date");
        $new_title = rtrim($new_title, " -");
    
        if (get_the_title($post_id) !== $new_title) {
            remove_action('wp_after_insert_post', 'update_objet_post_title_with_designer_and_latest_values', 10);
    
            // Sanitize slug for URL, ensuring accents are handled appropriately.
            $sanitized_slug = sanitize_title($new_title);
    
            wp_update_post([
                'ID'         => $post_id,
                'post_title' => $new_title,
                'post_name'  => $sanitized_slug,
            ]);
    
            add_action('wp_after_insert_post', 'update_objet_post_title_with_designer_and_latest_values', 10, 3);
        }
    }
    
    add_action('wp_after_insert_post', 'update_objet_post_title_with_designer_and_latest_values', 10, 3);
    
    in reply to: How to use the value of a custom Taxonomy ? #44635
    AnLipAnLip
    Participant

    So basically, where the snippet above has this line :

    $designer_post_id = rwmb_meta( 'related_designer_id', '', $post_id );

    it should be able to pull the value of the related post's title and insert it here.

    in reply to: How to use the value of a custom Taxonomy ? #44634
    AnLipAnLip
    Participant

    Hi Peter,

    The code is generated by ChatGPT, it invented some name for a custom field that does not exist (for the relationship), since the data I want to pull is coming from the Meta Box created Relationship (between two CPTs : "objet" and "designers").

    So the question again : how can you pull the data of a relationship while in the admin area and saving a post ?

    in reply to: How to use the value of a custom Taxonomy ? #44621
    AnLipAnLip
    Participant

    The post title is wrong, I do not need help anymore with pulling the taxonomy values (I have managed that in the provided above code).

    My only issue is with pulling the current post's related post's title, and inserting it in the newly generated title (before the date).

    in reply to: Querying Custom Taxonomy for Users in a User loop #42642
    AnLipAnLip
    Participant

    Thank you Peter, but I don't understand what you are suggesting.
    Could you provide a code that will work inside a Bricks User query ?

    in reply to: Using custom fields with Media Attachment #42499
    AnLipAnLip
    Participant

    Thanks Peter, have you also fixed the use of taxonomy fields being attributed to Media Attachments ?

    I have tried outputting custom text fields but with no success. Whether I use the Bricks dynamic data way or a code block and the PHP provided in the MB custom fields editor, either way the values don't show in the frontend. Using the Bricks dynamic data way in a Basic text element leaves the value as such : {mb_attachment_text_line_1} in the frontend, and using the codeblock just outputs nothing...

    in reply to: Using custom fields with Media Attachment #42392
    AnLipAnLip
    Participant

    Hi Peter,

    Any news for this matter ? It would be such a good addition to MetaBox...

    in reply to: Group Field just stopped working #41543
    AnLipAnLip
    Participant

    OK, issue solved : someone helped me on the MB facebook group stating I had many custom fields and the PHP max_input_vars was too low at 1000 so changing it 8000 solved the problem. I can now resave my group field as I want and the values have come back frontend and backend ! As mentioned by the person who helped me, the devs should really get a warning shown after a certain number of fields has been reached !!!

Viewing 15 posts - 1 through 15 (of 51 total)