Support Forum ยป User Profile

Forum Replies Created

Viewing 15 posts - 2,746 through 2,760 (of 3,958 total)
  • Author
    Posts
  • in reply to: Get an image url out of array #6222
    Anh TranAnh Tran
    Keymaster

    Hi,

    rwmb_meta( 'image_field_id' ) returns an array of image info. To get the URL of the image, simply use the code like this:

    $image_info = rwmb_meta( 'image_field_id', 'size=thumbnail' );
    echo $image_info['url']; // Thumbnail size URL
    echo $image_info['full_url']; // Full size URL
    in reply to: User role issue #6216
    Anh TranAnh Tran
    Keymaster

    Can you please try download again? I think I uploaded the wrong file.

    in reply to: User role issue #6211
    Anh TranAnh Tran
    Keymaster

    Hi,

    We probably haven't supported it yet. The user_role actually is the role for being edited users. It's not for the current user, who is editing. We'll update the extension to add more condition for the current user.

    in reply to: User role issue #6191
    Anh TranAnh Tran
    Keymaster

    Hi,

    Just realized that you asked about a field, not a meta box. The include / exclude extension works for meta boxes only, not for fields.

    So, in this situation, you probably need to use PHP code to check and register a field for a meta box. Something like:

    $fields = array(); // Define all your fields here
    if ( current_user_can( 'manage_options' ) ) {
        $fields[] = array(
            'type' => 'text',
            'name' => 'Custom field for admin only',
            'id'   => 'admin_only',
        );
    }
    
    // Register meta box
    $meta_boxes[] = array(
        'type'   => 'user',
        'title'  => 'Profile fields',
        'fields' => $fields,
    );
    in reply to: User role issue #6158
    Anh TranAnh Tran
    Keymaster

    The user_role is the role of the being edited users, not the current users. In this case, if you want to edit editor users, you need to set 'user_role' => 'editor'.

    in reply to: Cloned group with file_advanced field type #6157
    Anh TranAnh Tran
    Keymaster

    You can get file info with the helper function RWMB_File_Field::file_info( $file ), like this:

    $group = rwmb_meta('media');
    foreach($group as $data){
        $files = rwmb_meta($data['mb_file']);
        foreach($files as $file) {
            $file_data = RWMB_File_Field::file_info( $file );
            var_dump( $file_data );
        }
    }
    Anh TranAnh Tran
    Keymaster

    Dear Jason,

    As you can see, it says Undefined index: badgeos in /home/40951-69099.cloudwaysapps.com/czfybpbunb/public_html/wp-content/themes/obodohub-cts-master-0.5.2/functions.php on line 438.

    Can you please fix that warning?

    Cheers!

    in reply to: Add to Select Box with PHP Loop #6144
    Anh TranAnh Tran
    Keymaster

    Hello,

    Do you want to get list of custom post types or list of posts of some custom post types?

    In 1st case, you can use the function get_post_types() to get all the post types:

    $options = array();
    $post_types = get_post_types( array(
        'public'   => true,
        '_builtin' => false
    ), 'objects' );
    foreach ( $post_types as $post_type ) {
        $options[$post_type->slug] = $post_type->name;
    }

    And in the select, just set 'options' => $options.

    In the 2nd case, you can use the field type post and set 'post_type' => 'your_post_type', and all the posts will be populated in the select option. For more info, please check this guide.

    Anh TranAnh Tran
    Keymaster

    Just updated the plugin with the fix you provided :).

    Thanks for your contribution.

    in reply to: Conditional Logic Custom Callback not working for me #6117
    Anh TranAnh Tran
    Keymaster

    Dear bdthemes,

    Here is an example:

    
    add_filter( 'rwmb_meta_boxes', 'YOURPREFIX_register_meta_boxes' );
    
    function YOURPREFIX_register_meta_boxes( $meta_boxes ) {
        // Define a meta box
        $meta_box = array(
            'title'      => __( 'Media', 'textdomain' ),
            'post_types' => 'post',
            'fields'     => array(
                array(
                    'name' => __( 'URL', 'textdomain' ),
                    'id'   => 'url',
                    'type' => 'text',
                ),
            )
        );
    
        // Add new field when condition meets
        if (get_theme_mod( 'orphan_toolbar')) {
            $meta_box['fields'][] = array(
                'name'     => 'Toolbar',
                'id'       => $prefix . "toolbar", 
                'type'     => 'checkbox',
                'desc'     => 'Enable or disable the toolbar for this page.',
                'tab'      => 'layout',
            ),
        }
    
        // Add the meta box to $meta_boxes array to register
        $meta_boxes[] = $meta_box;
    }
    
    
    in reply to: Disable select option #6116
    Anh TranAnh Tran
    Keymaster

    Dear woorie,

    Because toggle_type is affected to whole field/meta box and its container and many fields aren't normal form input field so it isn't possible. Sorry for that.

    Anh TranAnh Tran
    Keymaster

    Dear Jason,

    Can you please tell me your PHP version, in the example I use anonymous function so perhaps it doesn't works with PHP 5.2.

    Btw, can you please turn on WP_DEBUG and/or WP_DEBUG_LOG to see the full output message. Kindly check the WP official documentation: https://codex.wordpress.org/Debugging_in_WordPress

    Best regards,
    Tan

    in reply to: Disable select option #6110
    Anh TranAnh Tran
    Keymaster

    Dear woorise,

    The plugin is intended to show or hide field or meta box, it cannot disable a field.

    Best,

    Tan

    in reply to: Conditional Logic Custom Callback not working for me #6109
    Anh TranAnh Tran
    Keymaster

    Dear bdthemes,

    Conditional Logic works with Javascript callback only, it doesn't works with PHP, however, with PHP, you can check if meet a condition and then register meta box or field, like so:

    
    if (get_theme_mod('orphan_toolbar')) {
        $meta_boxes = [
            ...
        ];
    }
    
    in reply to: Conditional Logic question/proposal #6091
    Anh TranAnh Tran
    Keymaster

    Dear kotofey,

    1. Yes, I'll add it to the next minor release this month.
    2. Yes, I have already written a guide for you.
    https://metabox.io/docs/hide-meta-box-tabs-conditional-logic/

Viewing 15 posts - 2,746 through 2,760 (of 3,958 total)