Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1,306 through 1,320 (of 3,958 total)
  • Author
    Posts
  • in reply to: I cannot get custom fields to display, thanks #13854
    Anh TranAnh Tran
    Keymaster

    Hi Sean,

    You're using field ID coaching_lesson_summary in the helper function. But the real ID is $prefix . 'coaching_lesson_summary', which is prefix-coaching_lesson_summary. So, your code should be:

    $value = rwmb_meta( 'prefix-coaching_lesson_summary' );
    echo $value;
    in reply to: Metabox Plugin issue #13841
    Anh TranAnh Tran
    Keymaster

    I got it. I've fixed it here. Can you take a look?

    Anh TranAnh Tran
    Keymaster

    Hi Ale, can you var_dump( $image_fields ) to see what values it has?

    in reply to: Metabox Plugin issue #13835
    Anh TranAnh Tran
    Keymaster

    I've just tested again on Firefox and Chrome and couldn't replicate the bug. Would you mind giving me the code for the slider field?

    in reply to: Metabox Plugin issue #13829
    Anh TranAnh Tran
    Keymaster

    Hi, thanks for your feedback. I'm checking it now.

    Anh TranAnh Tran
    Keymaster

    Hi Ale, can you post the code you use on those locations?

    in reply to: "mb_user_meta & mb_rest_api" has problem #13806
    Anh TranAnh Tran
    Keymaster

    Hi Jiro, you're right about the missing user in the update_user_meta call. I've just added that fixed.

    Regarding the var_dump, it's not strange as the field registry (where all fields are stored) is structured like this:

    object_type
      specific_type
        field 1
        field 2

    For posts, object_type is post and specific_type is post type. For terms, it's term and taxonomy. For users, as there's no specific type, we use user and user.

    in reply to: Take values from database in a select #13805
    Anh TranAnh Tran
    Keymaster

    Hi, you can do like this with Meta Box:

    First, separate the code that get list of BuddyPress groups into a function (it's a good practice to keep this logic away from plugins):

    function prefix_get_bp_groups() {
        global $wpdb;
        $table = $wpdb->prefix."bp_groups";
        $groups = $wpdb->get_results( "SELECT id,name FROM $table" );
    
        if ( !empty( $groups ) ) {
            return [];
        }
        $return = [];
        foreach( $groups as $group ) {
            $return[$group->id] = $group->name;
        }
        return $return;
    }

    Then register a meta box with the following code:

    add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
    function prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = [
            'title' => 'Your title',
            'fields' => [
                [
                    'id' => 'your_key',
                    'name' => 'BuddyPress group',
                    'type' => 'select',
                    'options' => prefix_get_bp_groups(), // THIS
                ],
            ],
        ];
        return $meta_boxes;
    }
    in reply to: Take settings values in add_action( 'init' #13804
    Anh TranAnh Tran
    Keymaster

    Hi, please change the priority in the add_action from 0 to something greater than 20. Meta Box plugin register fields at priority 20 (to make sure all custom post types and custom taxonomies are available when they also use the init hook with priority 10). So, changing it to a number greater than 20 makes the meta boxes and fields available and you're able to use the helper functions to get the value.

    in reply to: recaptcha #13794
    Anh TranAnh Tran
    Keymaster

    I'm afraid it's not possible. I'll see if we can add that to the plugin. This is a good idea.

    Anh TranAnh Tran
    Keymaster

    Hi,

    I think this can be done with custom JavaScript only. So you need to enqueue your JS file on the page that has the form, then in the code, when the form is being submitted, check if the value of the textarea is a mobile number or email address. If it is, then return false to prevent the submission.

    This is a pseudo-code that might give you some idea:

    jQuery( function( $ ) {
        $( '.your-form' ).on( 'submit', function() {
            var value = $( '#your-field' ).val();
            if ( checkIfIsMobileNumberOrEmail( value ) ) {
                return false;
            }
        } );
    } );
    in reply to: custom post type capabilities #13792
    Anh TranAnh Tran
    Keymaster

    It works fine, but when you add a custom capability then that capability needs to be given to any roles who need it, including administrators.
    This isn’t the responsibility of Meta Box, it’s up to the admin to provide the appropriate permissions to any roles that need it.

    That's correct. I think a plugin like Members would do the job better than Meta Box, since it's too verbose for capability management.

    I'll add the info to the docs when updating the plugin.

    in reply to: "mb_user_meta & mb_rest_api" has problem #13791
    Anh TranAnh Tran
    Keymaster

    Hi Jiro, please change the code for meta boxes to:

    add_action( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
    function prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
            'id' => 'personal',
            'title' => 'Personal Information',
            'type' => 'user', // Specifically for user
            'fields' => array(
                array(
                    'name'  => 'test mb for user',
                    'desc'  => '',
                    'id'    => 'test4',
                    'type'  => 'text',
                ),
            )
        );
        return $meta_boxes;
    }

    Your code has 2 issues:

    • The type of the field should not be string, it's text.
    • The function doesn't return $meta_boxes.

    I've just made a test with Postman and here is the result:

    https://imgur.elightup.com/F92ilAA.png

    in reply to: Required attribute doesn't work on image field #13772
    Anh TranAnh Tran
    Keymaster

    It's fixed here and will be available in the new version soon.

    in reply to: By Post Field 'query args' with author #13771
    Anh TranAnh Tran
    Keymaster

    Assume you have this code to register your meta box:

    add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
    function prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
            // Your meta box code goes here
        );
    }

    Then change it to:

    add_action( 'init', function() {
         add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
    } );
    function prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
            // Your meta box code goes here
        );
    }
Viewing 15 posts - 1,306 through 1,320 (of 3,958 total)