• I need help writing a SQL query that selects all users who do not have a particular usermeta field.

    It’s for a site where users can opt out of email communications from the site owner by ticking a tickbox on their admin dashboard.

    When they tick the box, it sets a usermeta with meta_key = ‘optout’ and meta_value = ‘yes’. If they then untick the box again, the usermeta field is deleted.

    So all users who are happy to receive emails don’t have this usermeta field.

    Can anyone tell me the SQL I need to retrieve all users who do not have a usermeta with the ‘optout’ meta_key?

    Thanks
    Simon

  • The topic ‘How to select users who do not have a usermeta field’ is closed to new replies.