Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 59 total)
  • Author
    Posts
  • in reply to: Path to validation language files is incorrect. #43203
    pluginovenpluginoven
    Participant

    Are you testing this in the default language?

    Try switching WordPress to another language...
    if ( file_exists( RWMB_DIR . "validation/i18n/messages_$locale.js" ) ) {...}
    And yes, we have tested both the RWMB_DIR and the RWMB_JS_URL constants, which is the reason of opening this thread.

    pluginovenpluginoven
    Participant

    the filter function is returning the $show_delete var. it was missing in the above example:

    function fix_frontend_delete_button ( $show_delete, $post_id ){
    	$post_type = get_post_type( $post_id ); //workplace
    	if ( !current_user_can( 'delete_'.$post_type.'s' ) ) {
    		$show_delete = false;
    	}
    	return $show_delete;
    }
    pluginovenpluginoven
    Participant

    For limiting a user to only create X amount of posts, we are using the mbfs_dashboard_add_new_button filter like so:

    add_filter( 'mbfs_dashboard_add_new_button', 'limit_num_of_workplaces', 20, 2 );
    function limit_num_of_workplaces( $add_new_button, $atts ) {
    	if( $atts['post_type'] == 'workplace' && current_user_can('some_user_role') ){
    		//how many workplaces does this user have? (we are limiting to 3)
    		if (count_user_posts( get_current_user_id(), $atts['post_type'], false ) > 2 ){
    			$add_new_button = ''; //no soup for you!
    		}
    		return $add_new_button;
    	}
    }
    pluginovenpluginoven
    Participant

    I would be delighted to explain, Tran!

    The short version is because developers build things beyond the default WordPress setup and want to use this great set of meta box plugins to do so.

    We are using WordPress along Meta Box and MB User Profiles to create rapid prototypes that include a large, and very complex set of Forms in the user profile area.So many fields, in fact, they needed to be grouped into Tabs. So Complex, in fact, we quickly outgrew using the MB Tabs extension and started using a very clever plugin called WP-User-Profiles to separate the field groups into Tabs. These tabs and sub-tabs have their own screen id's such as: "admin_page_services" for when the user is viewing a tab called "services" under their own profile and "users_page_services" when an admin is viewing a users's service tab. So far so good? good.

    Now, it's not a problem to have the meta-boxes appear in these new tabs in the user profile. we simply assign the post_types attribute when we create the metabox like so:

    'type' => 'user',
    'post_types' => ['admin_page_service','users_page_service','toplevel_page_service'],

    The problem, and the reason we have modified the mb-user-profiles plugin--well, actually the mb-user-meta plugin that is included in this plugin--as described above for the last four years is that all scripts that make metabox so nice for users profiles such as the validation, special advanced fields and so on are hard-coded to only be loaded on "user profiles" that have screen ids of:
    array( 'profile', 'user-edit', 'profile-network', 'user-edit-network' )

    Feel free to reach out to me on Github or directly via email if you would like to have a closer look at how we are using your plugins. It's probably one of the more advanced use cases given the number of times pull requests have been submitted when we run into a limitation.

    pluginovenpluginoven
    Participant

    Just a quick update.

    While this technically works, keep in mind that the is_edit_screen function will loop for each defined metabox. To make this more efficient, the core plugin's RW_Meta_Box class would need to be modified to allow the $edit_screens to be defined and filtered once then passing this array over, and over and over again to the is_edit_screen_

    in reply to: Open Street Maps OSM Isn't Autopopulating Fields #42138
    pluginovenpluginoven
    Participant

    Ah ha! It's only under the 'Multiple addresses' section that some hint is provided:

    'address_field' => 'address_id'

    So a simplified OSM example would look like this:

    $meta_boxes[] = [
                'id' => 'private_details_box',
                'title' => 'Private Address',
                'type' => 'user',
                'geo' => true,  // include the geo API
                'context' => 'normal',
                'priority' => 'high',
                'fields' => [
                    [
                        'type' => 'osm',
                        'name' => 'The Required OSM Map',
                        'address_field' => 'private_address' // tell the map which field to use
                    ],
                    [
                        'type' => 'text',
                        'name' => 'Private Address',
                        'id'    => 'private_address', // does NOT need to start with address
                    ],
                    [
                        'type' => 'text',
                        'name' => 'Street Address',
                        'id'    => 'private_street_address',
                        'attributes' => [
                            'binding' => 'streetaddress',
                            'required'  => true,
                        ],
                    ],
                    [
                        'type' => 'number',
                        'name' => 'Postal Code',
                        'id'    => 'private_postal_code',
                        'attributes' => [
                            'required'  => true,
                            'binding'   => 'postcode'
                        ],
                    ],
                ]
            ];
    in reply to: Open Street Maps OSM Isn't Autopopulating Fields #42137
    pluginovenpluginoven
    Participant

    I totally agree with @digisavvy that the documentation is for Geolocation is confusing. Extremely helpful would be a code example of how Google version with binding is structured and a separate code example for the OSM variant with binding.

    Of note: the animated demo of this extension shows the Google version, but the OSM version requires that an OSM map be included in the field group.

    in reply to: Prevent forms from rendering submit button #42116
    pluginovenpluginoven
    Participant

    Yes. this is a valid solution.
    This issue can be marked as resolved.
    Thank you.

    in reply to: Prevent forms from rendering submit button #42099
    pluginovenpluginoven
    Participant

    The suggested modifications to src/Forms/info.php are as follows:
    1. Add the class_submit attribute to the $config.

    $config = shortcode_atts( [
    			...
    			// Appearance options.
    			...
    			'id_password'       => 'user_pass',
    			'id_password2'      => 'user_pass2',
    			'id_submit'         => 'submit',
    			'class_submit'         => '',  // Add class_submit attribute
    			...
    ], $config );

    2. add $this->config['class_submit'] to the button class:

    protected function submit_button() {
    		?>
    		<div class="rwmb-field rwmb-button-wrapper rwmb-form-submit">
    			<div class="rwmb-input">
    				<button type="submit" class="rwmb-button <?= esc_attr( $this->config['class_submit'] ); ?>" id="<?= esc_attr( $this->config['id_submit'] ) ?>" name="rwmb_profile_submit_info" value="1"><?= esc_html( $this->config['label_submit'] ) ?></button>
    			</div>
    		</div>
    		<?php
    	}
    in reply to: Prevent forms from rendering submit button #42098
    pluginovenpluginoven
    Participant

    The CSS workaround would work if I could assign a class to the submit button. Is this possible? An ID can be assigned using the id_submit but then either:
    a) custom CSS to hide multiple submit buttons by their unique ID if they exist on the same page would need to be created. or
    b) a new id_class attribute would need to be added to the plugin allowing one CSS class definition to be used to hide the submit button.

    of course, something like id_submit="hidden_submit" could be used in conjunction with a single CSS ID definition, but then, when multiple forms are used on the same page (or in different tabs on the same page), multiple elements with the same ID would exist in the DOM. Not good.

    As many times before, I will modify the plugin to get around this issue for the immediate need and would be happy to submit a pull request.

    pluginovenpluginoven
    Participant

    Update. Since this plugin actually does include 'mb-user-meta', this is actually exactly the same issue as posted back in 2019. In this case, the file is found under:
    vendor > meta-box > mb-user-meta > src > MetaBox.php
    The function:

    public function is_edit_screen( $screen = null ) {
    		if ( ! is_admin() ) {
    			return false;
    		}
    		$screen = get_current_screen();
    		return in_array( $screen->id, ['profile', 'user-edit', 'profile-network', 'user-edit-network'], true );
    	}

    should be updated to:

    public function is_edit_screen( $screen = null ) {
    		if ( ! is_admin() ) {
    			return false;
    		}
    		$screen = get_current_screen();
    		// Allow edit screens to be expanded
    		$edit_screens = apply_filters( 'rwmb_user_edit_screens', [ 'profile', 'user-edit', 'profile-network', 'user-edit-network' ] );
    		return in_array( $screen->id, $edit_screens, true );
    	}

    I see that the array was changed from array() to []... yet the filter was not added.

    in reply to: Change register and login title above the form #40058
    pluginovenpluginoven
    Participant

    There is no option to change this title

    Yes there is. This is defined in the file mb-user-profile > src > DefaultFields.php at line 25:
    'title' => 'register',
    Why this is hardcoded is beyond me.

    It seems like every post I make ends the same way. Here to, this is true:


    @rilwis

    I am more than happy to contribute a pull request to either a) Allow the title to be translated:
    'title' => __( 'Register', 'mb-user-profile' ),
    or allow the title to be filtered / set to blank within the shortcode attributes.

    in reply to: Plugin is missing Localization POT File #33223
    pluginovenpluginoven
    Participant
    pluginovenpluginoven
    Participant

    Found the issue:
    fields/post.php line 181:
    public static function search_by_title( $search, &$wp_query ) {
    should be:
    public static function search_by_title( $search, $wp_query ) {
    remove the & symbol before the variable.
    Shall I submit a pull request?

    pluginovenpluginoven
    Participant

    Update:
    The issue appears to be coming from commit e5cb8b9

Viewing 15 posts - 16 through 30 (of 59 total)