12
Jan
2012

WordPress Remove WP Drop Down Links

I posted a small plugin over at WPMUDev for users, here it is again:

along with some code snippets on how to handle this:

http://premium.wpmudev.org/forums/topic/remove-wp-about-menu-from-toolbar#post-161711

There are a few options. First the manual edits:
Open the file:
/wp-includes/class-wp-admin-bar.php
And around line 456:

456
add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );

Comment it out or just remove the whole line. Now the WP links part is all gone! :-)
But….. But……… If you wanted to edit those links to customise yourself, you could just go open up the file:
/wp-includes/admin-bar.php
You’ll see it all near the top, here is a short snippet:

if ( is_user_logged_in() ) {
// Add "About WordPress" link	 $wp_admin_bar->add_menu( array('parent' => 'wp-logo', 'id' => 'about',	 'title'  => __('About WordPress'),	 'href'   => admin_url('about.php'),	 ) );
}

You will note much of the same on there.
The logo is part of a sprite which can be found here:

/wp-includes/images/admin-bar-sprite.png

Both of these options mean updating the code every time you upgrade your WP install.
And now the final option, which is the easiest, but its yet another plugin………

Remove WordPress Admin Bar Links

Enjoy, its free!! :-)

29
Mar
2011

Changing Your WordPress Multisite Admin Username – Network Admin

No doubt you found and followed some tutorials to change your admin user name, you most likely found some old MU tutorial and then found that your new WordPress 3.1 Network Admin menu/area just disappeared.

Well this quick set of pointers should help you out! ;-)

Log into your PHPMyAdmin or what ever you are using to edit your database.

1. Find the table “_users”.
2. Edit the row where the “user_login” column is equal to “admin”. Change the admin part to what ever is your desired user name.
3. Also edit the row where “user_nicename” column is equal to “admin” (same as above) Change this to your desired “nice” name (no spaces or such) – This is also used within BuddyPress for the profile link and @admin.
4. BuddyPress users will want to change their profile where it echoes out “admin”, this is located in the table “_bp_xprofile_data”.

Now you will most doubt have done all that but now can’t find the “Network Admin” link and section, well you need to edit one more thing:

5. Open the table “_sitemeta” There is a row “site_admins” with data under the column “meta-data”, it will look like this:

a:1:{i:0;s:5:"admin";}

You will want to change this including the number 5 which is the character count of your username, so in my instance it will look like this:

a:1:{i:0;s:3:"tim";}

Save and test it out, that should fix the issue for you.

Please note: There could well be other instances in the database on a multisite install, I haven’t thoroughly checked. I only worked through this to help another user find a solution, this worked for me and then worked for them. Always make a backup of your database first! ;-)

Hopefully this should help someone out there! :-)

24
Mar
2011

noreply@ wordpress@ Ripping Your Hair Out And Want To Change These?

You might find these when using BuddPress, Contact Form 7, WPMUDEV Supporter Form and no doubt it annoys you! ;-)

First of all if you are runing a vanilla install of WordPress you will have no doubt noticed that when system e-mails are sent out that the address is usually wordpress@yourdomain.com and of course you could most likely find a plugin to combat this but is a another plugin bloating your install really what you need?

So, where can you change this in the core code?

/wp-include/pluggable.php

Around line 391:

391
$from_email = 'wordpress@' . $sitename;

Around line 1057:

1057
$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));

So that is the default out of the way!

Now you are running BuddyPress and you notice that your “Contact Form 7″ or Supporter form is sending out e-mails with a sent address from noreply@yourdomain.com, of course this is damn annoying, it makes it more time consuming when you make replies, often you send an e-mail to yours noreply address and then get angry clients asking why you haven’t contacted them back, or if you use a support desk so you can’t just reply to that ticket. Its most annoying when all you need to do is reply yes or no and especially so when using the supporter form for your clients.

So the problem! It is actually buddypress causing the issue here. At least in 1.2.8 (Not checked other versions) You see it ads filters to the default WP_Mail function forcing its own headers. What you need to do is remove those filters and everything will be back working as it should.

Contact Form 7, Add the following:

remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');

In the compose_and_send_mail() function around line 693:

693
694
695
696
697
698
	function compose_and_send_mail( $mail_template ) {
 
		remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
		remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');
 
		$regex = '/\[\s*([a-zA-Z_][0-9a-zA-Z:._-]*)\s*\]/';

Now it will use what ever you stipulate in the admin area of Contact 7 which is usually the e-mail address for the person contacting you!

And the WPMUDEV Supporter plugin, open the following:

/wp-content/mu-plugins/supporter-premium-support.php

Add it to the supporter_support_page() function which is approx. line 94 it should then look like this:

94
95
96
97
98
function supporter_support_page() {
  global $current_user;
 
	remove_filter('wp_mail_from', 'bp_core_email_from_address_filter' );
	remove_filter('wp_mail_from_name', 'bp_core_email_from_name_filter');

You could if you wished wrap it up in some conditional statements to check for BuddPress first, but for me it is always installed, at least for now! ;-)

If you are not using BuddyPress or you still have this issue after removing the filters then chances are there is another plugin or even theme which is forcing its use of the wp_mail() function.

Note: One thing to remember is that making changes directly to the main files of WP, a plugin or theme means that when you come to upgrade you will need to remember to make those changes again! I prefer this over bloating an install with plugin after plugin. ;-)