Results 1 to 9 of 9

Thread: Wp3.0 delete user meta

  1. #1
    Rich Pedley's Avatar
    Rich Pedley is offline Hello World
    Join Date
    May 2009
    Location
    Liverpool, UK
    Posts
    92

    Icon5 Wp3.0 delete user meta

    As usual this may be a daft question, but how to I delete user meta based on key rather than user ID?
    the standard:
    PHP Code:
    <?php delete_user_meta$user_id$meta_key$meta_value ?>
    I think needs a user ID.

  2. #2
    andreasnrb's Avatar
    andreasnrb is offline Kegger
    Join Date
    Jun 2009
    Posts
    595

    Default

    You want to delete the user meta for all users?

  3. #3
    Rich Pedley's Avatar
    Rich Pedley is offline Hello World
    Join Date
    May 2009
    Location
    Liverpool, UK
    Posts
    92

    Default

    correct. user meta with a specific key.

  4. #4
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    865

    Default

    Short answer: you don't. Not with the standard calls.

  5. #5
    Rich Pedley's Avatar
    Rich Pedley is offline Hello World
    Join Date
    May 2009
    Location
    Liverpool, UK
    Posts
    92

    Default

    bah, was beginning to think as much, thanks for confirming.

  6. #6
    Ipstenu's Avatar
    Ipstenu is offline Big Tipper
    Join Date
    Feb 2010
    Posts
    368

    Default

    I'm at a loss at why you'd want to, though. Why do you want to?

  7. #7
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    865

    Default

    You could write your own SQL to do it easily enough if you really wanted to. Off the top of my head, DELETE FROM $wpdb->usermeta WHERE meta_key = 'whatever' would do the trick.

  8. #8
    andrea_r's Avatar
    andrea_r is offline WordPress Rockstar
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,325

    Default

    Yeah, I'd rather do something like that straight up in the SQL. :)

  9. #9
    Rich Pedley's Avatar
    Rich Pedley is offline Hello World
    Join Date
    May 2009
    Location
    Liverpool, UK
    Posts
    92

    Default

    why? tidying up on uninstall of a plugin.

    But yeah the query is easy enough, but if the facility was already there I would have preferred to use it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •