ABlueEyedMonkey
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: wp_signon successful but user is not logged inCould someone please confirm if that’s the correct way of doing things, so that I can at least rule out that the function is/isn’t the problem. Thanks guys
Forum: Plugins
In reply to: Query doubling up on loop_startOk i managed to find a solution, but I still don’t understand why it happened. If i change my code to:
add_action( "loop_start", "start" ); function start( $post ) { if(is_singular()) { global $wpdb; $USER_ACHIEVEMENTS_DB = $wpdb->prefix.PG_USER_ACHIEVEMENTS; $userAchievement = $wpdb->get_row("SELECT * FROM $USER_ACHIEVEMENTS_DB WHERE achievement = 'Explorer' AND user_id = 1"); $currentScore =(int)$userAchievement->score; //Print just before echo "before $currentScore"; $currentScore += 1; //increment //Call the update $wpdb->update( "$USER_ACHIEVEMENTS_DB", array( 'stage' => 1, 'level' => $currentScore, 'score' => $currentScore ), array( 'user_id' => 1, 'achievement' => "Explorer" ), array( '%d', "%s", '%d', ), array( '%d', '%s' )); echo "after $currentScore"; //This is correct. but in the DB its always double what I increment it with. die("FIN"); } else { echo "This never gets called??"; //Why if i add the singular check does this never get called? } }Then it works ok, but the else never gets called. So how can this function be getting called twice?
Viewing 2 replies - 1 through 2 (of 2 total)