Viewing 12 replies - 1 through 12 (of 12 total)
  • the link below will give you a function to determine whether a logged in user is of admin level or not. if so, the function will return true, otherwise, will return false. should be able to figure out from there. if not, let us know.

    http://csstyle.pastebin.com/7aMQpRya

    Thread Starter drinkliverpool

    (@drinkliverpool)

    All my users are Authors as its a personal gallery blog. One of the plugins i use is called Q&A plugin(http://wordpress.org/extend/plugins/q-and-a/). When I log in as an Admin, the FAQ setting tab appears directly under the COMMENTS button as it does when an Author logs in.

    I want this FAQ settings tab to appear for an ADMIN ONLY.

    you’ll need to edit the plugin manually. are you familiar with php and the structure of a plugin?

    Thread Starter drinkliverpool

    (@drinkliverpool)

    To be honest, i’m not too clever with PHP, trying to teach myself with a PHP5 book I bought but it just goes over my head. I know te VERY basics and that’s about it.

    I would love someone totell me what to change in the files of this plugin. 😉

    but if someone tells you what to do, you wont learn, and that’s the whole point of the forums 😉

    that being said.

    check out this page: http://codex.wordpress.org/Function_Reference/register_post_type. it’s information about the function register_post_type, which you will see at the top of the q-and-a.php file. use the ‘show_in_menu’ and the function provided earlier to create a conditional for display the tab.

    or, you could use a role manager plugin, and create a role specifically for the qa post type, and give only admins capabilities to add and edit that post type.

    Thread Starter drinkliverpool

    (@drinkliverpool)

    I give up. I just don’t understand it all. I tried messing around with what you said (to the limit of my understanding) and I also tried looking for a role manager plugin that’d do this but with no luck.

    I’ll just use a different FAQ plugin where the settings are already admin only. Thanks anyway.

    oh it is possible to do what you want, i just didnt want to give the answer away from the start. we can make it work with this plugin, if you need to use that plugin.

    Thread Starter drinkliverpool

    (@drinkliverpool)

    I’d rather use that plugin mainly for aesthetic purposes.

    I’d be eternally grateful if you could help me out and let me know what it is ur doing.

    Pleeeeease

    ok. open q-and-a.php, find in the function definition of create_qa_post_types the call to function register_post_type. you’ll see an array, with labels ‘labels’, ‘public’, ‘show_ui’, etc. go to the line starting with ‘supports’ (line 57), and add a comma to the end. add a new line, and copy and paste the code below into the blank line (now line 58).

    'show_in_menu' => (is_admin_login() ? true : false)

    when you’re done, the function call should look like this:

    register_post_type( 'qa_faqs',
    		array(
    			'labels' => array(
    				'name' => __( 'FAQs' ),
    				'singular_name' => __( 'FAQ' ),
    				'edit_item'	=>	__( 'Edit FAQ'),
    				'add_new_item'	=>	__( 'Add FAQ')
    			),
    			'public' => true,
    			'show_ui' => true,
    			'capability_type' => 'post',
    			'rewrite' => array( 'slug' => 'faq', 'with_front' => false ),
    			'taxonomies' => array( 'FAQs '),
    			'supports' => array('title','editor'),
    			'show_in_menu' => (is_admin_login() ? true : false)
    		)
    	);

    make sure you add the function i provided above to the plugin at the top, or in your theme’s functions.php. also note, that if you upgrade the plugin, you will have to make this change again (tho it may be different, seeing as how there are usually changes to the code when an upgrade is available).

    hope that helps.

    If you’re going to edit the plugin, then i’d suggest doing it by adjusting the required capabilities set in the plugin.

    First find this…

    function add_qa_option_page() {
    	// hook in the options page function
    	add_options_page('Q and A', 'Q and A', 6, __FILE__, 'qa_options_page');
    }

    Update that to read..

    function add_qa_option_page() {
    	// hook in the options page function
    	add_options_page('Q and A', 'Q and A', 'manage_options', 'questions-and-answers', 'qa_options_page');
    }

    ==============================
    YOU ONLY NEED THE ABOVE PART FOR THE SETTINGS PAGE
    ==============================

    Then find the following…

    //
    	register_post_type( 'qa_faqs',
    		array(
    			'labels' => array(
    				'name' => __( 'FAQs' ),
    				'singular_name' => __( 'FAQ' ),
    				'edit_item'	=>	__( 'Edit FAQ'),
    				'add_new_item'	=>	__( 'Add FAQ')
    			),
    			'public' => true,
    			'show_ui' => true,
    			'capability_type' => 'post',
    			'rewrite' => array( 'slug' => 'faq', 'with_front' => false ),
    			'taxonomies' => array( 'FAQs '),
    			'supports' => array('title','editor')
    		)
    	);

    Remove this part..

    'capability_type' => 'post',

    And put this in it’s place..

    'capabilities' => array(
    	'publish_posts' => 'manage_options',
    	'edit_posts' => 'manage_options',
    	'edit_others_posts' => 'manage_options',
    	'delete_posts' => 'manage_options',
    	'delete_others_posts' => 'manage_options',
    	'read_private_posts' => 'manage_options',
    	'edit_post' => 'manage_options',
    	'delete_post' => 'manage_options',
    	'read_post' => 'manage_options',
    ),

    The plugin will then work only for admins.

    Thread Starter drinkliverpool

    (@drinkliverpool)

    Excellent. Both soloutions worked. I have learned from this. 🙂

    Mark’s solution is def better. Thanks Mark.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Plugins for Admins’ is closed to new replies.