Title: Illeagal string offset
Last modified: June 28, 2019

---

# Illeagal string offset

 *  [thegreatest1](https://wordpress.org/support/users/thegreatest1/)
 * (@thegreatest1)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/illeagal-string-offset-2/)
 * Hello,
 * I get this message:
    /srv/users/……..includes/add-shortcode-if-user-is-logged-
   in.php on line 5
 * when implementing a plugin:
 * [https://www.solutionsawaken.com/showing-content-to-users-who-are-logged-in-and-who-are-not-logged-in-to-wordpress/](https://www.solutionsawaken.com/showing-content-to-users-who-are-logged-in-and-who-are-not-logged-in-to-wordpress/)
 * Line 5 is this line: if($atts[‘for_not_logged_in’] == “yes”) {
 * I tried this before and it worked, without a message, how can i fix this?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [t-p](https://wordpress.org/support/users/t-p/)
 * (@t-p)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/illeagal-string-offset-2/#post-11682567)
 * Your best bet is to contact the author of that third-party script.
 *  Thread Starter [thegreatest1](https://wordpress.org/support/users/thegreatest1/)
 * (@thegreatest1)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/illeagal-string-offset-2/#post-11682690)
 * Im sorry it should be: Warning: Illegal string offset for ‘for_not_logged_in’
   in /srv/…on line 5. This is line 5: if($atts[‘for_not_logged_in’] == “yes”) {
 * Could I change this to make it work?
 *  [autotutorial](https://wordpress.org/support/users/autotutorial/)
 * (@autotutorial)
 * [6 years, 10 months ago](https://wordpress.org/support/topic/illeagal-string-offset-2/#post-11682901)
 * it depends on how the code checks $atts if it’s empty I do what I have to do 
   after that code initializes the array.
    example
 *     ```
       if(empty($atts)){
       //this code
       }
       ```
   
 * if in any case the indexfor_not_logged_in is defined with yes or no
    This inizialized
   array `$atts = array();`
 *     ```
       $atts['indexfor_not_logged_in'] = 'yes';
       // For user without login
       ```
   
 *     ```
       $atts['indexfor_not_logged_in'] = 'no';
       // For user with login
       ```
   
 * if it is not present in all cases, I initialize the array as in the previous 
   code and add a verification of the existence of the index.
 *     ```
       if(!empty($atts['indexfor_not_logged_in']) && $atts['indexfor_not_logged_in'] == 'yes'){
       // Your code here
       }
       ```
   
 * [https://www.php.net/manual/en/language.types.array.php](https://www.php.net/manual/en/language.types.array.php)
 * For multidimensional array $arr[‘a’][‘b’] or $arr[‘a’][‘c’]
    `$arr = array('a'
   => array());`
 * the best way is to contact the developer that with php 7.1 => this problem exists
   🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Illeagal string offset’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [autotutorial](https://wordpress.org/support/users/autotutorial/)
 * Last activity: [6 years, 10 months ago](https://wordpress.org/support/topic/illeagal-string-offset-2/#post-11682901)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
