Viewing 15 replies - 16 through 30 (of 32 total)
  • OK, I’m not sure what the default ‘meta_compare’ is, but you may need to include ‘meta_compare’ => ‘LIKE’ in your query. But it looks like it should be able to handle finding a specific instrument in the comma separated list.

    Also you may need to wrap the ‘meta_value’ in wildcards too (i.e ‘%theory_lessons%’). But I’m not 100% sure, I’ll have to do some experimenting.

    Thread Starter planktonwebdesign

    (@planktonwebdesign)

    Yeah, I did the meta_compare to ‘LIKE’ and also tried ‘IN’ and ‘EXISTS’ and ‘BETWEEN’ but none of them worked if the user has checked a couple of options. Havn’t tried to break up the options with spaces with a str_replace and see if it works, would I add the %’s to the options when creating them or in the query?

    I’m recreating your scenario I’ll let you know when I get it working.

    Thread Starter planktonwebdesign

    (@planktonwebdesign)

    Cool, here is an example of what I have going in the template if that helps

    // the url is nzmusicteachers.co.nz/theory-lessons
    // the extra field key is rpr_instruments, values are theory_lessons,trumpet_lessons,guitar_lessons
    
    		$slug = basename(get_permalink()); // Page Slug which is theory-lessons
    		$service = str_replace("-", "_", $slug); // so theory-lessons becomes theory_lessons
    
    		$professional_crew = array(
    			'role' => 'professional',
    			'meta_key' => rpr_instruments,
    			'meta_value' => $service,
    			'meta_compare' => 'LIKE'
        	);
    
        ////////////       Professional       ////////////
    
    	// Create the WP_User_Query object
    
    		$wp_user_query = new WP_User_Query($professional_crew);
    
    	// Get the results
    
    		$authors = $wp_user_query->get_results();
    
    	// Check for results
    
    		if (!empty($authors)) {
    
    		// loop through each author
    
    	    	foreach ($authors as $author) { 
    
    	    		// do stuff like
    
    	    		$instruments = get_the_author_meta('rpr_instruments');
    	    		$no_underscores = str_replace("-", "_", $instruments);
    	    		echo str_replace(", ", ",", $no_underscores); // add a space after the comma
    
    			}
    
    		}

    OK, well I got it to work on my site. I couldn’t mess with the role because I don’t have that defined, but I believe that your only problem is that rpr_instruments isn’t quoted, change it to ‘rpr_instruments’ and you should start getting results.

    Thread Starter planktonwebdesign

    (@planktonwebdesign)

    Grr I just whacked that example together so shouldn’t have made that mistake on my actual template. If you have it working I’ll need to try looking harder at my code as it might be something like that that is stopping it from working.

    Thanks so much for taking the time to look at this. Is my str_replace the best way to go to output stuff so it looks like the label I setup in RPR?

    You must be busy so no dramas as I can roll with my hodge podge of code.

    Thanks again! Is is possible to ask you to paste your code here so I can see how you got it going to make sure I’m on the right track?

    No problem, let me preface that I use a plugin called Shortcode Exec PHP so that I can run PHP directly without needing a page so I’m running with less overhead then you. But here’s the code I wrote that works:

    $service = 'theory_lessons';
    $user_query = new WP_User_Query(array('meta_key' => 'rpr_instruments',
    	'meta_value' => $service,
    	'meta_compare' => 'LIKE'));
    if ( !empty( $user_query->results ) ) {
    	foreach ( $user_query->results as $user ) {
    		echo '<p>', $user->display_name, '</p>';
    	}
    } else {
    	echo 'No users found.';
    }

    Oh, as for the str_replace, that looks good enough to me. I’m going to include a new option for you, well, for everyone, to disable my aggressive cleanup code. With this feature enabled the_author_meta would output something less manipulated, in your case “Trumpet Lessons,Theory Lessons” instead of “trumpet_lessons,theory_lessons”. The problem with that is that it would actually complicate your code further because your slug “theory-lessons” wouldn’t match “Theory Lessons”, you’d actually have to texturize the slug which is harder then the reverse.

    OK, I kept looking at this and realized I caused a regression from Redux 3.7.3. Your values should have been stored in the database in their full format, “Trumpet Lessons,Theory Lessons”. I have fixed this because it will break potentially thousands of sites that upgrade from 3.7.3 to 3.9.

    What does that mean for you? Hm. Change $service = str_replace("-", "_", $slug); to $service = str_replace("-", " ", $slug);. Otherwise you should be good, at least in my demo site that’s all I had to do. Let me know how that works for you.

    Thread Starter planktonwebdesign

    (@planktonwebdesign)

    Hey Radiok,

    I’ll look into this when I update to 3.9.2 saw the upgrade notice ??

    I’ve pushed the site to a testing server, bugger is the registration process isn’t saving any of the additional extra fields ?? I can go in an edit my profile and save them which is great but the initial registration isn’t saving anything.

    I’m using theme my login too. Do you reckon there is a conflict when you register?

    staging.nzmusicteachers.co.nz

    Thread Starter planktonwebdesign

    (@planktonwebdesign)

    Bugger just did a test. I disabled Theme my Login (6.2.3) and the extra fields all save as expected.

    So there must be a conflict once you click register, I’ll try disabling some of the redirection and email notification things I have setup in Theme My Login and try using the options available in RPR and see if I can get it to work.

    Yup, I can’t see Register Plus Redux and Theme My Login working well together anytime soon. I think they may have played well together long ago but Theme My Login has grown and grown nearly to be a full fledged competitor to Redux. You’ll have to let me know if there are any features from Theme My Login that you cannot recreate in Redux.

    Thread Starter planktonwebdesign

    (@planktonwebdesign)

    It’s really just having the login form and register pages in the template:

    https://staging.nzmusicteachers.co.nz/login

    https://staging.nzmusicteachers.co.nz/join-up/?action=register form is down the bottom of this page

    Register Plus has everything except having forms in the front end and some redirect to stop subscribers going to backend on login etc

    The old site nzmusicteachers.co.nz has them working together but the versions are old like you said hmm. Might have to sit on this for a bit?

    I see, that actually is a to-do on my bucket list, making a shortcode droppable registration form so that you can create a page and have the registration form wherever. There’s just a lot of complications with that. I’m very particular about my code so it has to work “my” way which makes life harder then it ought to be but, eh.

    Anyway, the problem is that I have to create registration form definitions, basically I have one now, you can add and remove from it but I don’t allow for multiple definitions at this point. It’s a whole layer of administration I haven’t had the strongest desire to code.

    So yes, it’s neat and others have done it, I’m just not sure when I will.

    PS- Your page made me notice something that you may want to resolve now to prevent future problems. Your checkbox’s have leading spaces. I must assume your Instruments/Services field has the following options, “Bassoon Lessons, Clarinet Lessons, Double Bass Lessons, etc”. You may want to change that to “Bassoon Lessons,Clarinet Lessons,Double Bass Lessons,etc”. It will make the meta side look nicer and also be more future proof. I should probably attempt to trim each of the comma separated values, and might following this thread, but either way another bucket list item is to define the checkbox, select, and radio options in a list instead of that textbox. A) It’ll be easier to see all your defined options, and B) it’s more logical. That’s a significantly more forthcoming change, probably in the next month or so.

Viewing 15 replies - 16 through 30 (of 32 total)
  • The topic ‘[Plugin: Register Plus Redux 3.9] Checkbox value not saving’ is closed to new replies.