• Resolved nickaster

    (@nickaster)


    Hi there – I have a generic “guest author” account (a user) that I use for many guest posters – I just give them the login/pass and let them go to town as a “contributor”. 99% of the time this works just great.

    However, every once in a while someone edits the user bio to be their own. It’s an innocent mistake, but a total pain in the ass because suddenly hundreds of posts get attributed to them instead of “guest author”.

    Anyway – is there a way to make the bio/name fields NON EDITABLE for a particular user to prevent this?

    THanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Why not put the kybosh on allowing the “guest user” (aka user_id 376) to save anything at all from the profile page?

    <?php
    add_action( 'personal_options_update', 'ds_profile_lockout' );
    function ds_profile_lockout() {
    	global $current_user;
    		if( $current_user->ID == '376' )
    		wp_die(__('You do not have permission to edit this user.'));
    }
    ?>

    Add to mu-plugins.

    Alternatively, if the guest user is the only user with role “contributor” remove the edit_user cap from that role.

    <?php
     	/*
    	Plugin Name: Edit Contributor
    	Plugin URI:
    	Description: Edits the contributer role
    	Author:
    	Author URI:
    	*/
    
    	$edit_contributor = get_role('contributor');
    	$edit_contributor->remove_cap('edit_user');
    
    ?>

    Add to plugins.
    (pluginspiration)

    Thread Starter nickaster

    (@nickaster)

    thanks! excellent. So… where is mu-plugins? is that part of a theme? If I make that change is it considered a hack of sorts that I should be concerned about?

    mu-plugins will be a folder inside wp-content next to your original plugins folder. Use it for snips of code/plugins you want to run as a “must use”. When you upgrade WP, mu-plugins stays just as it is.

    You could give the file a proper plugin header and put into plugins, too. It just makes sense to me to activate it as mu-plugin so users – even the admin – can’t deactivate it easily.

    Thread Starter nickaster

    (@nickaster)

    okay – thanks a ton. But what do I call the file? I’ll create an “mu-plugins” folder, then make a file with the text above in it….what do I save it as? anything.php?

    Thread Starter nickaster

    (@nickaster)

    ah ha! answered my own question, worked like a charm. THANK YOU!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘REstrictions for a particular user….’ is closed to new replies.