10 replies [Last post]
maxaud
Offline
newbie
Sandpoitn Idaho
Last seen: 10 years 6 days ago
Sandpoitn Idaho
Timezone: GMT-8
Joined: 2009-11-27
Posts: 4
Points: 5

I'm trying to style some items in the admin panel of WordPress MU using hooks so I don't have to modify the core.

I'm trying to style some form elements that have name attributes like user_name[1], user_name[2], and user_name[3].

I'm trying to use css attribute selectors to style them but it doesn't seem to be taking.

Could this be caused by the brackets "[]" in the attributes value?
These brackets are added by WordPress. There are no id's or class's applied to these form elements so I'm unsure of how to modify them.

Thanks in advance for any replies.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Where are user names shown in

Where are user names shown in this fashion with the user ID in square brackets, can't see that view on my install.

The brackets are just part of the rendered text string and shouldn't affect styling.

If you are trying to use attribute selectors, how are you trying to use them? What attributte are you attempting to target?

I have had, as usual, to ask too many questions, please provide sufficient detail so that we can actually provide some answers rather than more questions.

Tell me the page in the backend that these elements occur on, show us exactly! what rules you have tried to apply.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

maxaud
Offline
newbie
Sandpoitn Idaho
Last seen: 10 years 6 days ago
Sandpoitn Idaho
Timezone: GMT-8
Joined: 2009-11-27
Posts: 4
Points: 5

A URL that would show an

A URL that would show an example would be:
YourWordPressInstall.com/wp-admin/wpmu-blogs.php?action=editblog&id=1

One example would be the password fields for users on the right hand side of the screen.
They have the following code:
<input type='text' name='user_password[1]' />
the number changes for each user id

The code I'm using to style it is:

<style type="text/css" media="screen">
	input[name=user_password[1]] {
		display:none;
	} 
</style>

I also tried it with quotes around the selector value:

<style type="text/css" media="screen">
	input[name="user_password[1]"] {
		display:none;
	} 
</style>

This is added via a function to the admin_notices hook.
I have other styles here that are working.

Thanks for your help.

Verschwindende
Verschwindende's picture
Offline
Guru
Last seen: 35 weeks 3 days ago
Timezone: GMT-4
Joined: 2009-10-09
Posts: 2040
Points: 2262

Don't target using the name

Your URL doesn't work.

Don't target using the name attribute. Use a class or the input type instead.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Ah get want you mean now,

Ah get want you mean now, sadly I haven't yet got into the detail of WPMU styling and I'm running BP so the themes files and method of styling are looking god awful from what little I have had to fathom so far.

Due to the specific nature of WPMU and of BP, if that is involved, I would think that this question is far more appropriately asked of the WP forums than this one.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Verschwindende
Verschwindende's picture
Offline
Guru
Last seen: 35 weeks 3 days ago
Timezone: GMT-4
Joined: 2009-10-09
Posts: 2040
Points: 2262

Why are you styling an admin

Why are you styling an admin page anyway? Even when I release a WP theme to a client the admin section stays the same.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Versh has touched on a point

Versh has touched on a point I was intending on asking, but first give this a try:

input[name^=user_password] This does remove the input for me and if on a page / blog basis you shouldn't need to identify the user ID?

Back to the reasoning here firstly if you really need to do this I would have thought it's more appropriate to do via php not through styling, you are not really trying to style the layout you are seeming to want to prevent the possibility of someone changing values.

Secondly why are you wanting to do this this is an admin function why are you trying to restrict an admin? it's the point of being an admin and of having that privilege level in order to change these sorts of aspects.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 11 hours 7 min ago
Dallas
Timezone: GMT-6
Joined: 2004-06-25
Posts: 9745
Points: 3824

The following worked for

The following worked for Firefox and Opera:

input[name="user_name[1]"] {
    font-size: 2em;
    } /* single quotes worked as well, but fails with no quotes */
=================
  <input type="text" name="user_name[1]" />
Is that what you meant; the attribute selectors?

Not tested in IE6-8.

When reporting problems, be sure to indicate which browsers are involved.

cheers,

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 4 years 47 weeks ago
London
Joined: 2004-06-06
Posts: 15668
Points: 2806

Interesting didn't work for

Interesting didn't work for me Gary and I tested on an actual example of the element in context on my WPMU & BP install. probably better to go with my suggestion as it removes the requirement to know which user Id is being shown; also it did not fail with no quotes, only tested in FF 3.5.5

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

maxaud
Offline
newbie
Sandpoitn Idaho
Last seen: 10 years 6 days ago
Sandpoitn Idaho
Timezone: GMT-8
Joined: 2009-11-27
Posts: 4
Points: 5

Verschwindende wrote: Your

Verschwindende wrote:

Your URL doesn't work.

Don't target using the name attribute. Use a class or the input type instead.

The URL was an example URL for a wpmu installation. Since it is located in the WordPress Admin panel, it requires Site Admin access which I cannot give out. The items are dynamically generated with no hooks near by. I don't want to modify core code to add class/id attributes to it.

Hugo wrote:

Ah get want you mean now, sadly I haven't yet got into the detail of WPMU styling and I'm running BP so the themes files and method of styling are looking god awful from what little I have had to fathom so far.

Due to the specific nature of WPMU and of BP, if that is involved, I would think that this question is far more appropriately asked of the WP forums than this one.

What I'm doing is a little advanced. I'm touching on the multi-site capabilities of WordPress MU by running multiple sites, and domains off of one install. I'm basically running multiple WordPress MU installs off of one set of core files. I need to style specific user id's password fields so users that belong to a different site id cannot be edited by site admins of a different site. This is one downfall of a shared user base on a WordPress mu installation.

Verschwindende wrote:

Why are you styling an admin page anyway? Even when I release a WP theme to a client the admin section stays the same.

As stated, this is kind of an advanced deployment. It will run multiple WordPress MU instances off of one set of files and I need to be able to control what passwords can be changed by what the users primary blogs site_id is. Even if this wasn't the case, to style an admin panel to match the site would probably be an added benefit for your clients. Though I've never done it.

Hugo wrote:

Versh has touched on a point I was intending on asking, but first give this a try:

input[name^=user_password] This does remove the input for me and if on a page / blog basis you shouldn't need to identify the user ID?

Back to the reasoning here firstly if you really need to do this I would have thought it's more appropriate to do via php not through styling, you are not really trying to style the layout you are seeming to want to prevent the possibility of someone changing values.

Secondly why are you wanting to do this this is an admin function why are you trying to restrict an admin? it's the point of being an admin and of having that privilege level in order to change these sorts of aspects.

I'll try what you've presented but I need a way to specify a certain id depending on what the site_id of the users primary blog.

gary.turner wrote:

The following worked for Firefox and Opera:

input[name="user_name[1]"] {
    font-size: 2em;
    } /* single quotes worked as well, but fails with no quotes */
=================
  <input type="text" name="user_name[1]" />
Is that what you meant; the attribute selectors?

Not tested in IE6-8.

When reporting problems, be sure to indicate which browsers are involved.

cheers,

gary

I'll try that, but it looks near identical to my code. I'm using FF 3.5.5

Thanks for your replies and questions.

maxaud
Offline
newbie
Sandpoitn Idaho
Last seen: 10 years 6 days ago
Sandpoitn Idaho
Timezone: GMT-8
Joined: 2009-11-27
Posts: 4
Points: 5

Ok, I was able to get it to

Ok, I was able to get it to work.

Basically, my php code looks like this:

// Blog users
$blogusers = get_users_of_blog( $id );
 
if ($blogusers) {
	foreach ($blogusers as $bloguser) {
		echo 'input[name="user_password['.$bloguser->user_id.']"],';
	}
	echo 'input[name="user_password[1]"]{
			display:none;
		}
		';
}

That's not my final code because I have to make it check against what site_id the user belongs to.
I found that if my css string of elements/selectors ended with a comma it broke, so I simply just made it output user_password[1] again to put something after the last comma.