Forums › Forums › Search & Filter Pro › Remove Form create/edit rights from Site Admins
- This topic has 3 replies, 2 voices, and was last updated 9 years, 5 months ago by Ross.
-
Anonymous(Private) April 17, 2015 at 3:25 pm #15318
Hi there!
We’re using Search and Filter Pro in a multisite setup, where we’d like to remove the ability to create/edit forms from regular Site Admins. Instead, our team of developers will create forms for those people that need them, and plop the widgets/shortcodes out for them.
We’re able to easily remove the Menu Item and corresponding pages from the dashboard from non-super-admins, but the hardcoded link inside of the Widget itself is a little annoying to remove. “(Don’t see a Search Form you want to use? Create a new Search Form)” While we could try to hide this with some clunky jQuery, that sounds annoying – especially to maintain through updates, etc.
We were hoping you’d help us address this problem in some way.
For example, applying a filter to that text so that we could easily just return “” instead of that sentence that contains the link.
Another option would be giving this sentence a more unique id so that we can easily and consistently hide it with custom css in the admin area.
A more extensive approach might involve custom capabilities, so this (and other) code is wrapped in something like if ( current_user_can( ‘create_search_filter_form’ ) ) { …
Of course, we could hack that line out of the plugin, but we obviously want to keep the update process as simple as possible.
Thoughts?
Ross Moderator(Private) April 18, 2015 at 9:12 am #15339Hey there
Good catch! In my dev version I’ve just added a couple of classes which should make hiding this much easier.. Update the code in
includes\class-search-filter-register-widget.php
.Replace the function
form
(line 75) with this one:function form( $instance ) { if (( isset( $instance[ 'title' ]) ) && ( isset( $instance[ 'formid' ]) )) { $title = __(esc_attr($instance['title']), $this->plugin_slug); $formid = esc_attr($instance[ 'formid' ]); } else { $title = __( '', $this->plugin_slug); $formid = __( '', $this->plugin_slug); } ?> <div class="sf-widget-content"> <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p> <p> <label for="<?php echo $this->get_field_id( 'formid' ); ?>">Choose a Search Form: <select class="widefat" name="<?php echo $this->get_field_name( 'formid' ); ?>" id="<?php echo $this->get_field_id( 'formid' ); ?>"> <option value="0"><?php _e('Please choose'); ?></option> <?php // $custom_posts = new WP_Query('post_type=search-filter-widget&post_status=publish&posts_per_page=-1'); if ( function_exists('icl_object_id') ) { $formid = icl_object_id($formid, 'search-filter-widget', true, ICL_LANGUAGE_CODE); } //var_dump($custom_posts); while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?> <option value="<?php the_ID(); ?>" <?php if($formid==get_the_ID()){ echo ' selected="selected"'; } ?>><?php the_title(); ?></option> <?php endwhile; ?> </select> </label> </p> <p class="sf-widget-text-last"> <?php _e('Don\'t see a Search Form you want to use? <a href="'.admin_url( 'post-new.php?post_type=search-filter-widget' ).'">Create a new Search Form</a>.'); ?> </p> </div> <?php }
Now you should have no worries about upgrading the plugin 🙂
Thanks!
Anonymous(Private) June 1, 2015 at 10:56 pm #18665Hi,
We recently updated to 1.4.3 and noticed that the “sf-widget-text-last” class which we were using to hide the “Don’t see a Search Form you want to use? Create a new Search Form” message is not included in the plugin. It would be great if you could include the classes from your reply in the latest version so that we can easily update as new versions are released without having to modify the plugin to remove this line.
Thanks!
Ross Moderator(Private) June 2, 2015 at 10:57 am #18702Hey there
Good catch – I had some time ago already applied this to the 2.0 branch I was working on, I just hadn’t applied it to the 1.x branch when applying bug fixes…
S&F 2.0 should be out in the next couple of weeks and definitely had this class applied 🙂
Thanks
-
AuthorPosts