Support Forum ยป User Profile

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • in reply to: Not working for multiple entries again... #3473
    jonwatson87jonwatson87
    Participant

    Working again now... :/ Maybe it just took a bit of time for everything to clear and I was being impatient? Things usually start working immediately after a cache clear! Sorry! Overreacting, AGAIN.

    in reply to: Not working for multiple entries again... #3472
    jonwatson87jonwatson87
    Participant
    	//Panelists
    
    	$meta_boxes[] = array(
    			'title'      => 'Panelists',
    			'context'    => 'normal',
    			'priority'   => 'high',
    			'post_types' => 'events',
    			'desc'       => '(drag to reorder)',
    			'fields' 	 => array(
    				array(
    						'id'         => 'radix_panelists',
    						'type'       => 'group',
    						'clone'      => true,
    						'sort_clone' => true,
    						'fields'     => array(
    							array(
    									'name'  => 'Position',
    									'id'    => $prefix . 'panelistposition',
    									'type'  => 'text',
    									'desc'  => 'Position on panel: e.g. Panelist, or Chair',
    							),
    							array(
    									'name'  => 'Name',
    									'id'    => $prefix . 'panelistname',
    									'type'  => 'text',
    									'desc'  => 'Name of panelist',
    							),
    							array(
    									'name'  => 'Title',
    									'id'    => $prefix . 'panelisttitle',
    									'type'  => 'text',
    									'desc'  => 'Title of panelist',
    							),
    							array(
    									'name'  => 'URL',
    									'id'    => $prefix . 'panelisturl',
    									'type'  => 'text',
    									'desc'  => 'Link or mailto: for panelist',
    							),
    							array(
    									'name'  => 'Profile Pic',
    									'id'    => $prefix . 'panelistpic',
    									'type'  => 'file_input',
    									'desc'  => 'Profile picture of panelist',
    							),
    					),
    				),
    			),
    	);
    in reply to: if ! empty $groupvariable not working #3469
    jonwatson87jonwatson87
    Participant

    No worries, Anh! Hope you figure it out ๐Ÿ™‚ Not a problem to bypass it with a checkbox as long as people are aware of the issue.

    in reply to: if ! empty $groupvariable not working #3459
    jonwatson87jonwatson87
    Participant

    Confirmed. The default white space is somehow being saved as a populated field when the post is updated.

    I renamed the group and the if !empty worked. I updated a post, leaving these fields blank, and it stopped working.

    Even if these fields are left blank, the empty fields still register as being content and if !empty returns true.

    I'm gonna use a checkbox to hide this section for now and query that instead.

    in reply to: Returning CPT meta array, if not empty #3318
    jonwatson87jonwatson87
    Participant

    Awesome! ๐Ÿ˜€

    Thanks, Anh!

    in reply to: Returning CPT meta array, if not empty #3301
    jonwatson87jonwatson87
    Participant

    Full code, if it helps anyone in future (note that I had to adapt it slightly for use with Co-Authors Plus, so it echoes user_login with the prefix cap- and then uses that in the tax_query):

    // Return an array of radix_authoraccount, if not empty, for management, board and fellows post types
    
    	$teamargs = array(
    		'post_type' => array('management','fellows','board'),
    		'posts_per_page' => -1,
    	);
    
    	$team_posts = wp_get_recent_posts( $teamargs );
    
    	$theteamauthors = array();
    
    		foreach( $team_posts as $teamauthors ) { 
    
    	 		if (rwmb_meta( 'radix_authorcheckbox', '', $teamauthors['ID']) == 1 ) {
    
    	 			$teamauthorlist = rwmb_meta( 'radix_authoraccount', '', $teamauthors['ID']);
    
    				$getpostauthor = get_user_by( 'id', $teamauthorlist );
    				$authorlogin = $getpostauthor->user_login;
    
    	 			$theteamauthors[] = array('cap-' . $authorlogin);
    
    	 		}
    
    	 	}
    
    // Sort array to remove duplicate authors
    
    	// print_r($teamauthorlist);
    
    	$authorarray = array_unique($theteamauthors, SORT_REGULAR);
    
    	$authormap = array_map('array_pop', $authorarray);
    
    	$theauthors = implode(",",$authormap);
    
    	// echo $theauthors;
    	
    // Run query to retrieve active posts by these authors
    
    	$args = array(
    	    'numberposts' => '10',
    	    'orderby' => 'post_date',
    	    'order' => 'DESC',
    	    'post_type' => array( 'post', 'work', 'news' ),
    	    'meta_query'     => array(
    			array(
    				'key'     => 'radix_status',
    				'value'   => 'value1',
    				'compare' => '==',
    				)
    		),
    		'tax_query' => array(
    			array(
    				'taxonomy' => 'author',
    				'field' => 'slug',
    				'terms' => explode(',', $theauthors)
    			)
    		)
    	);
    
    	$recent_posts = new WP_Query ($args);
    
    	if ( $recent_posts->have_posts() ) {
    
    		echo '<div class="teamworklist"><ul>';
    
    		while ( $recent_posts->have_posts() ) {
    			$recent_posts->the_post();
    
    			// Post Title
    
    			$title = apply_filters( 'genesis_post_title_text', get_the_title() );
    			echo '<li>';
    			echo sprintf( '<h1 class="team-work entry-title"><a href="%s" rel="bookmark">%s</a></h1>', get_permalink(), $title );
    
    			// Post Date
    
    			echo get_the_date();
    			echo '<br>';
    
    			// Authors
    
    			echo 'By ';
    
    			coauthors_posts_links();
    
    			echo '</li>';
    
    		}
    
    		echo '</ul></div>';
    
    	} else {
    
    	}
    in reply to: Returning CPT meta array, if not empty #3300
    jonwatson87jonwatson87
    Participant

    GOT IT!

    Seems that the "user" field has a value even if it isn't selected, hence my need to put in a checkbox to begin with.

    I changed the if statement to the checkbox value and returned radix_authoraccount values based on that, instead.

    Final, working code:

    // Return an array of radix_authoraccount, if not empty, for management, board and fellows post types
    
    	$teamargs = array(
    		'post_type' => array('management','fellows','board'),
    		'posts_per_page' => -1,
    	);
    
    	$team_posts = wp_get_recent_posts( $teamargs );
    
    	$teamauthorlist = array();
    
    		foreach( $team_posts as $teamauthors ) { 
    
    	 		if (rwmb_meta( 'radix_authorcheckbox', '', $teamauthors['ID']) == 1 ) {
    
    	 			$teamauthorlist[] = array(rwmb_meta( 'radix_authoraccount', '', $teamauthors['ID']));
    
    	 		}
    
    	 	}
    
    // Sort array to remove duplicate authors
    
    	// print_r($teamauthorlist);
    
    	$authorarray = array_unique($teamauthorlist, SORT_REGULAR);
    
    	$theauthors = array_values( $authorarray );
    
    	print_r($theauthors);

    Thanks for being my sounding board!

    in reply to: Returning CPT meta array, if not empty #3298
    jonwatson87jonwatson87
    Participant

    Latest update:

    I got it returning SOME values, by using:

    // Return an array of radix_authoraccount, if not empty, for management, board and fellows post types
    
    	$teamargs = array(
    		'post_type' => array('management','fellows','board'),
    	);
    
    	$team_posts = wp_get_recent_posts( $teamargs );
    
    	$teamauthorlist = array();
    
    		foreach( $team_posts as $teamauthors ) {  
    
    	 		if ( !empty( array(rwmb_meta( 'radix_authoraccount', '', $teamauthors['ID']) ) ) ) {
    
    	 			$teamauthorlist[] = array(rwmb_meta( 'radix_authoraccount', '', $teamauthors['ID']));
    
    	 		}
    
    	 	}
    
    // Sort array to remove duplicate authors
    
    print_r($teamauthorlist);
    
    $authorarray = array_unique($teamauthorlist, SORT_REGULAR);
    
    $theauthors = array_values( $authorarray );
    
    // print_r($theauthors);'

    But the values returned aren't quite right... According to the user data I can see, and the users assigned using radix_authoraccount, I should be getting:

    234455678

    Instead, the above code is returning:

    2333445578

    That's two extra 3s and a missing 6... Getting closer, but something's not quite right...

    in reply to: Returning CPT meta array, if not empty #3297
    jonwatson87jonwatson87
    Participant

    So, I've got the array and sorting to work, but not with radix_authoraccount... if I change 'radix_authoraccount' to a standard post field, like 'post_title', and 'SORT_NUMERIC' to 'SORT_REGULAR' (because title is no longer a numeric value) it works perfectly - printing the array of values minus the two duplicates.

    Any idea how I can get this to work with 'radix_authoraccount'?

    // Return an array of radix_authoraccount, if not empty, for management, board and fellows post types
    
    	$teamargs = array(
    		'post_type' => array('management','fellows','board'),
    	);
    
    	$team_posts = wp_get_recent_posts( $teamargs );
    
    	$teamauthorlist = array();
    
    	foreach( $team_posts as $teamauthors ) {
    
    		if ( !empty( array($teamauthors['radix_authoraccount']) ) ) {
    
    			$teamauthorlist[] = array($teamauthors['radix_authoraccount']);
    
    		}
    
    	}
    
    // Sort array to remove duplicate authors
    
    	$authorarray = array_unique($teamauthorlist, SORT_NUMERIC);
    
    	$theauthors = array_values( $authorarray );
    
    	print_r($theauthors);
    in reply to: Issue getting group to save/load on front end #3254
    jonwatson87jonwatson87
    Participant

    100% correct! Sorry, Anh! Feel like an idiot now! Clearing the cache is usually the first thing I do! XD

    Thanks so much for the help!

    in reply to: Issue getting group to save/load on front end #3225
    jonwatson87jonwatson87
    Participant

    Okay, loading fine on the front end now! Must've mis-copied/pasted something.

    Still not letting me add more than 1 group record, however...

    jonwatson87jonwatson87
    Participant

    Same issue - group will only save one record. Any new records added just replace the first one.

    Whereabouts is the new code on GitHub?

    in reply to: Troubleshooting post meta-values #3083
    jonwatson87jonwatson87
    Participant

    Nevermind! I think I've figured it out ๐Ÿ™‚

    in reply to: Serious Site Issue After Updates #2684
    jonwatson87jonwatson87
    Participant

    Completely uninstalled the plugins, downloaded the very latest versions and reinstalled. Seems to have done the trick!

    in reply to: Serious Site Issue After Updates #2681
    jonwatson87jonwatson87
    Participant

    Okay, I've fixed the front end issue by replacing "rwmb_get_field" calls with "rwmb_meta"

    However, still having the back end issue that posts and metaboxes aren't showing up properly.

Viewing 15 posts - 1 through 15 (of 19 total)