Support Forum ยป User Profile

Forum Replies Created

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • in reply to: [Request] Preventing any user-input #6692
    ttroelsttroels
    Participant

    Yeah, I guessed that it's the only solution for now. But if you implement it to a future extension or as the base pack I would be happy ๐Ÿ™‚

    in reply to: Validation does not work for fields in group #6678
    ttroelsttroels
    Participant

    Yes, I use the basic HTML5 validation as well, but I would like to implement both HTML5 and JS validation. Seems it don't quite work in cloneable groups. It's just for informing you about the issue ๐Ÿ˜‰

    in reply to: Validation does not work for fields in group #6664
    ttroelsttroels
    Participant

    Here I discovered that the validation does work in groups, but only the first group.
    If I create a cloneable group, so the other groups and fields don't have any validation in them, because the fields now have different id's than defined in our validation rules...

    in reply to: [Request] Preventing any user-input #6658
    ttroelsttroels
    Participant

    Hi

    Thank you for the reply. No, I don't submit any fields to frontend. I'm building a custom backend system to register data (of people), and I have multiple users and each have difference roles and capabilities. Some can only view part of data, and edit the other part - while other roles can edit all the fields - so I need a way to "control" which fields is uneditable.
    As the 'disabled' and 'readonly' attributes is only controlled in frontend in the user's own browser, I can't ensure that they don't edit the attributes, allowing them to edit the fields they are not allowed to edit.
    Thus, in this case my definition of "frontend" is actual WP admin backend, where users can either edit or read the difference fields.

    I hope that it's to understand now? ๐Ÿ™‚

    Best
    Troels

    in reply to: Heading as revision #6579
    ttroelsttroels
    Participant

    Thank you for the wonderful service!

    in reply to: Sortable custom admin columns? #4480
    ttroelsttroels
    Participant

    Perhaps you can apply the filter in the next update of Admin Columns, so I still in the future can filter the sortable_columns to add more custom columns which I want to being filtered ๐Ÿ™‚

    in reply to: Sortable custom admin columns? #4479
    ttroelsttroels
    Participant

    Hi again!

    I think we misunderstood each other. What I want is that the column "Navn" is clickable and can be sorted ASC or DESC according to the user interaction, and not let it's order being defined in backend.

    I solved it myself by digging in your code. The best solution is to apply a filter in the sortable_columnsfunction in base.php:

    public function sortable_columns( $columns ) {
    	foreach ( $this->fields as $field ) {
    		if ( is_array( $field['admin_columns'] ) && ! empty( $field['admin_columns']['sort'] ) ) {
    			$columns[ $field['id'] ] = $field['id'];
    		}
    	}
    	$columns = apply_filters( 'add_sortable_columns', $columns );
    	return $columns;
    }

    and tell my custom.php to add the filter:

    function __construct() {
    	parent::__construct( 'mm_medlem', array() );
    	// Other code
    	add_filter( 'add_sortable_columns', array( $this, 'add_sortable_columns' ) );
    }

    and

    public function add_sortable_columns( $columns ) {
    		$columns['navn'] = 'navn';
    		return $columns;
    }
    in reply to: Sortable custom admin columns? #4459
    ttroelsttroels
    Participant

    Thank you for the reply. But I can't make head or tail in the approach. Here is my code. How should I modify this to let me sort the "name" column?

    
    <?php
    class MM_Medlem_Custom_Admin_Columns extends MB_Admin_Columns_Post {
    	/**
    	 * MM_Medlem_Custom_Admin_Columns constructor.
    	 */
    	function __construct() {
    		parent::__construct( 'mm_medlem', array() );
    		add_action( 'pre_get_posts', array( $this, 'filter' ) );
    	}
    
    	public function columns( $columns ) {
    		$columns = parent::columns( $columns );
    
    		/**
    		 * Add more column in a specific position
    		 *
    		 * @param string $position New column position. Empty to not specify the position. Could be 'before', 'after' or 'replace'
    		 * @param string $target The target column. Used with combination with $position
    		 */
    		$position = 'after';
    		$target   = 'mm_ddi-nr';
    		$this->add( $columns, 'navn', 'Navn', $position, $target );
    
    		return $columns;
    	}
    
    	public function show( $column, $post_id ) {
    		switch ( $column ) {
    			case 'navn':
    				$navn = '';
    
    				$fnavn = get_post_meta( $post_id, 'mm_fornavn', true );
    				$mnavn = get_post_meta( $post_id, 'mm_mellemnavn', true );
    				$enavn = get_post_meta( $post_id, 'mm_efternavn', true );
    
    				$navn .= $fnavn;
    				if ( $mnavn ) {
    					$navn .= ' ' . $mnavn;
    				}
    				$navn .= ' ' . $enavn;
    
    				echo $navn;
    				break;
    		}
    	}
    
    	function filter( $query ) {
    		$query->set( 'orderby', 'mm_fornavn' );
    		$query->set( 'order', 'ASC' );
    	}
    }
    
Viewing 8 posts - 1 through 8 (of 8 total)