Quantcast
Viewing all articles
Browse latest Browse all 5527

lacheney on "Query Wordpress database by registered date and role"

Sorry to be a pain. This is my full code. What I'm trying to do is extract each display name and each email from the result and put them through a loop:

<?
    mysql_connect("localhost", "DBUSER", "DBPASS") or die(mysql_error());
	mysql_select_db("DB") or die(mysql_error());

    $result = mysql_query("SELECT user_login, user_email, meta_key, meta_value FROM wp_usermeta, wp_users WHERE wp_users.ID = wp_usermeta.user_id AND wp_usermeta.meta_key = 'wp_15_user_level' AND wp_usermeta.meta_value = 0 AND wp_users.user_registered LIKE '2014-01-15%'");

$row = mysql_fetch_row($result);

//-------------------------- You need to set these --------------------------//
	$sendy_installation_url = 'URL'; //Your Sendy installation (without the trailing slash)
	//---------------------------------------------------------------------------//

	foreach ($row as $individual)
	{
        //-------- Subscribe --------//
        $postdata = http_build_query(
            array(
            'name' => THE DISPLAYNAME FIELD
		    'email' => THE EMAIL FIELD
		    'list' => "xoYWaOYnRsu6KPliTC70Gg",
		    'boolean' => 'true'
            )
        );
        $opts = array('http' => array('method'  => 'POST', 'header'  => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
        $context  = stream_context_create($opts);
        $result = file_get_contents($sendy_installation_url.'/subscribe', false, $context);
        //-------- Subscribe --------//
	}

 ?>

My problem isn't the rest of the code, it's filling those variables. How do I extract individual items from the array?

Thanks again


Viewing all articles
Browse latest Browse all 5527

Trending Articles