How do I deactivate a plugin for some roles

I’ve tried this for the plugin BP Activity Share but it doesn’t seem to work… this is what I have, where am I going wrong? /**disable the BP Activity share for all except admin**/ add_action(‘admin_init’, ‘my_filter_the_plugins’); function my_filter_the_plugins() { global $current_user; if (in_array(‘Participant’, ‘Subscriber’, $current_user->roles)) { deactivate_plugins( // deactivate for participant and subscriber array( ‘/bp-activity-share/bp-activity-share.php’ … Read more

Insert all post IDs in new database table

I have a plugin which creates a new database table. Upon activating the plugin is there a way to insert all my posts ids into that table? Right now I’m using an action hook to immediately insert the id of new posts I publish. function transfer_post_id($post_ID) { global $wpdb; if (!($wpdb->get_row(“SELECT post_id FROM $my_table WHERE … Read more

Order get_users() by last login date. Is it possible?

I want to create a page that displays all the blog users ordered by the last login date. I’ve tried with the get_users() function and I can succesfully get the users’ list, but not in the order I want: $query = get_users(‘&offset=”.$offset.”&orderby=login&order=DESC&number=”.$number); I think that the orderby=login is not what I”m looking for… Is there … Read more

Is it good practice to use wpdb->query() function?

I am using custom php code to perform data insertion, deletion, updating and other tasks. I am able to insert data into a table in two different ways, $wpdb->insert($table_name, array(‘id’ => NULL, ‘name’ => ‘$name’, ’email’ => ‘$email’, ‘city’ => ‘$city’)); and $sql = “INSERT INTO $table_name VALUES(”, ‘$name’, ‘$email’, ‘$city’)”; $wpdb->query($sql); Is it a … Read more

Fatal error when trying to get admin email on contact form

I’m building a contactform that needs to send all queries to the admin mail adress. The php file which processes the entered data and sends the email has only contains this code: <?php $admin_email = get_option(‘admin_email’); if($_POST[“name”] != “” && $_POST[“contact”] != “” && $_POST[“comments”] != “”) { echo “Uw bericht is verzonden! “; $name … Read more

More than one meta field in a single meta box?

I’m following this tutorial by Justin Tadlock on creating meta boxes. http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/ I can get a meta box with a single field to work without problem but I would like to create a meta box with several fields. For example a meta box called “Staff Details” with 2 fields called “Title” and “Experience”. Does anyone … Read more