Tag Info

Hot answers tagged

2

On the profile page exists a global variable $profileuser. The member $profileuser->roles is an array of all roles for that user. <?php # -*- coding: utf-8 -*- // Plugin Name: personal_options add_action( 'personal_options', 'print_user_roles'); function print_user_roles() { global $profileuser; print '<pre>$profileuser->roles = ' ...


2

You can add actions to the set_user_role hook: add_action( 'set_user_role', 'wpse98904_remove_demoted_user_posts', 10, 2 ); function wpse98904_remove_demoted_user_posts( $demoted_author_id, $role ) { if( 'subscriber' == $role ) { // In here you'd search for all the posts by the user $args = array( 'numberposts' => ...


1

You could also do this, function mod_redirect_subscriber_delete($user_id) { $user = get_user_by('id', $user_id); $role = $user->roles[0]; if ($role == 'subscriber') { add_action("deleted_user", function(){ wp_redirect( admin_url('/index.php') ); exit; }); } } add_action("delete_user", "mod_redirect_subscriber_delete"); ...


1

a) delete_user hook: Here is one idea: Add this into your code to delete the user: remove_action("delete_user", "mod_redirect_subscriber_delete"); wp_delete_user($user_id); where we remove the action callback to prevent it calling it self again. So your code becomes: function mod_redirect_subscriber_delete($user_id) { $user = get_user_by('id', ...


1

The "Contributor" role has very little access to anything on the back end but can created posts. delete_posts edit_posts read http://codex.wordpress.org/Roles_and_Capabilities#Contributor For comparison, an ordinary "Subscriber" has the last of the three, so "Contributor" has only two extra capabilities. I am not quite sure what "access ...


1

Users roles are changed by the WP_User object firing the set_role() function. At the end of that function on line 815 of wp-includes/capabilities.php there is an action to hook to: do_action( 'set_user_role', $this->ID, $role ); So, in your functions.php or in a plugin, you can grab that data as the hook fires after the user capability update, and ...


1

Filter the 'comments_open' check. It happens inside of the function with the same name, and that function is called in a theme usually like this: comments_open() and comment_form( array ( 'comment_notes_after' => '' ) ); This is how the filter works: add_filter( 'comments_open', 'wpse_98775_comment_check', 10, 2 ); function ...


1

This may be similar to what you are looking for, it doesn't force a category, but doesn't let the user submit the new post unless at least one category is selected This solution requires jQuery, but with little modification can be ported to plain JavaScript //intercept the "update" or "publish" button $("#post").submit(function(e){ //grab the GET query ...



Only top voted, non community-wiki answers of a minimum length are eligible