1

Very challenging: I have been looking for a solution to my Wordpress problem for weeks now and have already come close, but still not achieved any solution...

I created a wordpress website LOCALLY in WP 3.8 and then put it up online. Locally it works totally fine, but online I have a problem: I cannot login into my admin dashboard via /wp-login. All I get is a white screen.

After trying out different things I found out that the cause of the problem is the extra functions.php in my childtheme. I am using the Skeleton theme and in the childtheme folder I put a functions.php which only contains the code for a custom post type (for an events page).

My findings so far:

  • Renaming the plugins folder and deactivating plugins doesn't help, I still can't login. I created a seperate wordpress website which a fresh Skeleton theme installation and put a functions.php with my custom post type code into the childtheme folder, but still: I can't login.
  • The same trouble I have when I switch to other themes, for instance the standard WP themes.
  • Login to my admin dashboard ALWAYS works (no matter what theme I am using) if I deactivate the extra functions-file by renaming or deleting it.
  • When I see the white screen as a result of my login problem there are no errors displayed, although I put two lines of codes for displaying errors on top of the file (see below).
  • Transfer-Typ in Filezilla is set to "Automatic". I then put the transfer type to "ASCII" for manually transferring the functions.php to my childtheme, but still no solution to my problem...

Maybe a server problem?

A friend included the functions-php locally in a wordpress installation of his and everything worked fine. So I am thinking about a possible server problem. Therefore I checked the log files of my domain provider in order to see which notifications come up after my login attempts:

For testing I logged in at 10:29h WITHOUT the extra functions.php file in the wordpress childtheme; and then at 10:30h I logged in WITH this file that then causes the login error. Here come the resulting notifciations:

++++++++++++++++ GENERAL LOGFILE: ++++++++++++++++

10:29h:

78.34.243.22 - as [06/Jan/2014:10:29:33 +0100] "POST /wordpresstest/wp-login.php HTTP/1.1" 302 970 "...mydomain/wordpresstest/wp-login.php?loggedout=true" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "...mydomain"

78.34.243.22 - as [06/Jan/2014:10:29:34 +0100] "GET /wordpresstest/wp-admin/ HTTP/1.1" 200 62361 "...mydomain/wordpresstest/wp-login.php?loggedout=true" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "...mydomain"

78.34.243.22 - as [06/Jan/2014:10:29:38 +0100] "GET /wordpresstest/wp-login.php?action=logout&_wpnonce=350e4eadb6 HTTP/1.1" 302 2211 "...mydomain/wordpresstest/wp-admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "...mydomain"

78.34.243.22 - as [06/Jan/2014:10:29:38 +0100] "GET /wordpresstest/wp-login.php?loggedout=true HTTP/1.1" 200 4510 "...mydomain/wordpresstest/wp-admin/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "...mydomain"

10:30h:

78.34.243.22 - as [06/Jan/2014:10:30:11 +0100] "POST /wordpresstest/wp-login.php HTTP/1.1" 200 177 "...mydomain/wordpresstest/wp-login.php?loggedout=true" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "...mydomain"

78.34.243.22 - as [06/Jan/2014:10:30:29 +0100] "GET /wordpresstest/wp-login.php HTTP/1.1" 200 4071 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" "...mydomain"

++++++++++ ERROR-LOG ++++++++++

10:29h -> NO error log notifications

10:30h -> YES, there are the following error log notifications:

[Mon Jan 06 10:30:12 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-login.php on line 415, referer: ...mydomain/wordpresstest/wp-login.php?loggedout=true

[Mon Jan 06 10:30:12 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-login.php on line 427, referer: ...mydomain/wordpresstest/wp-login.php?loggedout=true

[Mon Jan 06 10:30:12 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-includes/pluggable.php on line 678, referer: ...mydomain/wordpresstest/wp-login.php?loggedout=true

[Mon Jan 06 10:30:12 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-includes/pluggable.php on line 679, referer: ...mydomain/wordpresstest/wp-login.php?loggedout=true [Mon Jan 06 10:30:12 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-includes/pluggable.php on line 680, referer: ...mydomain/wordpresstest/wp-login.php?loggedout=true [Mon Jan 06 10:30:12 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-includes/pluggable.php on line 896, referer: ...mydomain/wordpresstest/wp-login.php?loggedout=true

[Mon Jan 06 10:30:29 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-login.php on line 415

[Mon Jan 06 10:30:29 2014] [error] [client 78.34.243.22] PHP Warning: Cannot modify header information - headers already sent by (output started at /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-content/themes/skeleton_childtheme/functions.php:1) in /is/htdocs/wp11219728_2Z29VZF37V/www/wordpresstest/wp-login.php on line 427

As it looks the functions.php in the childtheme causes the error log notifications! I am new to PHP and Wordpress so that I cannot interpret then.

  • Maybe someone of you knows this problem and can interpret the error log notifcations?
  • And maybe someone of you can even include the functions.php in one of his/her online wordpress sites and check if it also causes a login error when put into the childtheme folder?

Your help would be fantastic!!! :)

And here is the code of my extra functions.php file from my childtheme folder:

<?php

    add_action( 'init', 'add_cpt_veranstaltungen' );

    function add_cpt_veranstaltungen() {

    $labels = array(
          'name' => _x('Veranstaltungen', 'post type general name'),
          'singular_name' => _x('Veranstaltung', 'post type singular name'),
          'add_new' => _x('Hinzufügen', 'Veranstaltung'),
          'add_new_item' => __('Neue Veranstaltung hinzufügen'),
          'edit_item' => __('Veranstaltung bearbeiten'),
          'new_item' => __('Neue Veranstaltung'),
          'view_item' => __('Veranstaltung ansehen'),
          'search_items' => __('Nach Veranstaltungen suchen'),
          'not_found' =>  __('Keine Veranstaltungen gefunden'),
          'not_found_in_trash' => 
          __('Keine Veranstaltungen im Papierkorb'),
          'parent_item_colon' => ''
       );

    $supports = array( 'title', 'editor', 'thumbnail', 'excerpt');

    $args = array(
          'labels' => $labels,
          'public' => true,
          'publicly_queryable' => true,
          'show_ui' => true, 
          '_builtin' => false,
          'show_in_menu' => true, 
          'query_var' => true,
          'rewrite' => array("slug" => "produkte"),
          'capability_type' => 'post',
          'hierarchical' => false,
          'has_archive' => true, 
          'hierarchical' => false,
          'menu_position' => 20,
          'supports' => $supports
       ); 

    register_post_type('veranstaltungen',$args);

       }


   add_action("admin_init", "cpt_veranstaltungen_meta_boxen");
   add_action('save_post', 'cpt_veranstaltungen_speichern');


   function cpt_veranstaltungen_meta_boxen(){
      add_meta_box("uhrzeit-meta", "Uhrzeit", "cpt_veranstaltungen_feld_uhrzeit", "veranstaltungen", "side", "high");
      add_meta_box("treffpunkt-meta", "Treffpunkt", "cpt_veranstaltungen_feld_treffpunkt", "veranstaltungen", "side", "high");
      add_meta_box("kurzbeschreibung-meta", "Kurzbeschreibung", "cpt_veranstaltungen_feld_kurzbeschreibung", "veranstaltungen", "side", "high");
   }


   function cpt_veranstaltungen_feld_uhrzeit(){
      global $post;
      $custom = get_post_custom($post->ID);
      $uhrzeit = $custom["uhrzeit"][0];
      echo '<input name="uhrzeit" type="time" value="' . $uhrzeit . '"/>';
   }

    function cpt_veranstaltungen_feld_treffpunkt(){
      global $post;
      $custom = get_post_custom($post->ID);
      $treffpunkt = $custom["treffpunkt"][0];
      echo '<textarea name="treffpunkt">' . $treffpunkt . '</textarea>';
   }

    function cpt_veranstaltungen_feld_kurzbeschreibung(){
      global $post;
      $custom = get_post_custom($post->ID);
      $kurzbeschreibung = $custom["kurzbeschreibung"][0];
      echo '<textarea name="kurzbeschreibung">' . $kurzbeschreibung . '</textarea>';
   }


   function cpt_veranstaltungen_speichern(){
      global $post;
      update_post_meta($post->ID, "uhrzeit", $_POST["uhrzeit"]);
      update_post_meta($post->ID, "treffpunkt", $_POST["treffpunkt"]);
      update_post_meta($post->ID, "kurzbeschreibung", $_POST["kurzbeschreibung"]);
   }



   add_action( 'init', 'cpt_reg_tax' );

   function cpt_reg_tax() {

   register_taxonomy( "Datum", 
       array( "veranstaltungen" ), 
       array(  "hierarchical"      => true, 
               "label"             => "Datum", 
               "singular_label"    => "Datum", 
               "rewrite"           => true));

   }



   add_filter("manage_edit-veranstaltungen_columns", "cpt_veranstaltungen_spalten");
   add_action("manage_posts_custom_column", "cpt_veranstaltungen_neue_spalte");

   function cpt_veranstaltungen_spalten($columns){
      $columns = array(
                 // Schema: key --> Ausgabe
                 "cb" => "<input type=\"checkbox\" />",  // standard
                 "title" => "Veranstaltung",             // standard
                 "uhrzeit" => "Uhrzeit",                 // NEU
                 "treffpunkt" => "Treffpunkt",           // NEU
                 "kurzbeschreibung" => "Kurzbeschreibung",  // NEU
                 "date" => "Hinzugefügt"                 // standard
      );

      return $columns;
   }




   function cpt_veranstaltungen_neue_spalte($column){
      global $post;

      if ("uhrzeit" == $column) {
         $custom = get_post_custom();
         echo $custom["uhrzeit"][0];
      }

      elseif ("treffpunkt" == $column) {
         $custom = get_post_custom();
         echo $custom["treffpunkt"][0];
      }

      elseif ("kurzbeschreibung" == $column) {
         $custom = get_post_custom();
         echo $custom["kurzbeschreibung"][0];
      }


   }

+++ UPDATE +++

Removing the ?> at the end of the code does not help.

Still not solved the problem, but might help much: http://codex.wordpress.org/Answers-Trouble_Shooting#Headers_already_sent

Via this link I learnt that the first line of the functions.php causes some problem that affects other files (see error log notifications at 10:30h above). But what exactly can be wrong here? Maybe someone of you can test the file online in a wordpress installment?

+++ PROBLEM SOLVED! +++

Many thanx to Tasos Bitsios: He helped me finding out the problem. I opened the functions.php-file in a Hex Editor and saw that there are three characters in front of the php start tag that shouldn't be there. I removed these characters, saved the file and uploaded it on my server and voilá: LOGIN WORKS!

Martin Bean
  • 38,379
  • 25
  • 128
  • 201
MaxNagler
  • 69
  • 3
  • 10

3 Answers3

1

Remove the trailing ?> from functions.php. PHP closing tags are optional* and are the usual culprits behind problems like this.

See also: Skipping PHP end tag

**most of the time*

EDIT: The problem might actually be in another file, no matter what the log says. I would search all invovled .php files in that project with the following regular expressions:

Beginning tag: ^.+<\?

End tag: ?>.+$

These will match beginning tag that are not in the beginning of their line, or end tags that are not at the end of their line.

If you have cygwin, you can go to the root of your project and do:

find . -iname "*php" | xargs grep -E "^.+<\?"
find . -iname "*php" | xargs grep -E "?>.+$"

Otherwise use a windows-based tool like powergrep.

EDIT 2: The problem in this case was that Max's code editor wasn't showing 3 special characters before the <?php tag. A hex editor revealed them.

Community
  • 1
  • 1
Tasos Bitsios
  • 2,699
  • 1
  • 16
  • 22
  • i just did, it doesn't help – MaxNagler Jan 07 '14 at 14:04
  • And the first line begins with ` – Tasos Bitsios Jan 07 '14 at 14:05
  • yeah, definitely without spaces. I feel desperated... may u have the possibility to test the file in an online wordpress installment of yours? – MaxNagler Jan 07 '14 at 14:06
  • Are you developing on Windows or Mac/Linux? – Tasos Bitsios Jan 07 '14 at 14:07
  • I'm developing on Windows 7 – MaxNagler Jan 07 '14 at 14:11
  • Edited my question to help you search for "bad" start/end tags. If you still can't find it, re-download the files from the server to another location on your disk and search there as well. – Tasos Bitsios Jan 07 '14 at 14:16
  • And just for fun, try viewing that functions.php file in a hex editor. It should start as: 3c 3f 70 68 70 ( – Tasos Bitsios Jan 07 '14 at 14:22
  • wow, that's very advanced for me. I just downloaded such an editor (HxD) and made a screenshot of what i am seeing when opening my functions.php in it: http://de.tinypic.com/view.php?pic=20qmibr&s=5#.UswPbPTuLfI – MaxNagler Jan 07 '14 at 14:31
  • hey, looking closer at the screenshot I just realized there are three characters before the – MaxNagler Jan 07 '14 at 14:35
  • what still interests me: how was it possible that these three characters got there? how can I avoid in the future that things like that happen? – MaxNagler Jan 07 '14 at 14:51
  • No worries :) I suspect the likeliest culprit is your code editor. A good IDE/code editor would *definitely* show any special/non-printable characters. Try Notepad++ or jEdit if you want something free/light, but still powerful as an editor. If you want a full-blown IDE, try Eclipse or Netbeans. – Tasos Bitsios Jan 07 '14 at 15:21
0

Remove the error reporting directives (ini_set and error_reporting) from the top of the file. You shouldn’t be using them and instead using the error levels WordPress has set for consistency (there’s a WP_DEBUG constant in wp-config.php you can set to true during development).

The reason you’ll be getting the “white screen of death” is, you’ve set error reporting to E_ALL (which reports all and any errors). So even if you have the slightest syntax error, PHP is going to print an error message (because you’ve enabled display_errors) and any calls to header() (which the login process will call) will result in an error because output’s already been printed to the screen.

You also shouldn’t be displaying errors in a production environment, as it gives nefarious users pointers as to your site’s weak points. As I say, set the WP_DEBUG to true during development to catch any errors.

Martin Bean
  • 38,379
  • 25
  • 128
  • 201
  • thank you for your answer. I just removed the error reporting directives from the functions.php-file and also in wp-config I set WP_DEBUG to true but still: I only get a white screen when trying to log in... In your second paragraph you write about E_ALL: so your opinion is that because I somewhere enabled "display_errors" I get this white screen because there might be a little syntax error??? where could this "display_errors"-setting be and how do I get rid of it? – MaxNagler Jan 07 '14 at 13:24
  • I’m not sure without seeing the website. Your error log’s the best place to look for the answer. – Martin Bean Jan 07 '14 at 15:20
0

This is the first thing you should do:

  • Download the file mentioned in the error message by using FTP or whatever file management application your host provides.

  • Open that file in a plain text editor (NOT MS Word or similar.Notepad or BBEdit are fine).

  • Check that the very first characters are

  • Check that the very last characters are ?>

  • Re-upload the file by using FTP or whatever file management application your host provides.

This and error interpreting you can find here.

cretzzzu3000
  • 221
  • 1
  • 7
  • thanx, your link comes very close to the solution. by the way I already included in the file but forget to mention it in the code in my post (just added it to my post). Via your link I learnt that the first line of the functions.php causes some problem that affects other files (see error log notifications). But what exactly can be wrong here? – MaxNagler Jan 07 '14 at 13:49
  • perhaps a BOM character casues this error? it is invisible with naked eye, but you can see it in your ftp client if you edit the file online. Usually it exist at the very top of the file, before any opening tags – andrew Jan 07 '14 at 14:13
  • opening the file in filezilla with the text editor doesn't reveal any character at the top of the file... – MaxNagler Jan 07 '14 at 14:22