• Is it possible to pass a URL parameter to a hidden field? I can’t get it to work.

    Custom plugin adds the parameter ‘special’

    add_filter('query_vars', 'parameter_queryvars' );
    
    function parameter_queryvars( $qvars ) {
        $qvars[] = 'special';
        return $qvars;
    }

    Metabox setup tries to assign it to a $parentref variable:

    add_filter( 'rwmb_meta_boxes', 'mylink_register_meta_boxes' );
    function mylink_register_meta_boxes( $meta_boxes ) {
    	global $wp_query;
    	if (isset($wp_query->query_vars['special']))
    	{
    		$parentref = $wp_query->query_vars['special'];
    	}

    and later

    array(
                    'id'   => $prefix . 'hidden',
                    'type' => 'hidden',
                    'std'  => $parentref,
                ),

    the add url for the metabox post looks like
    http://mydomain.com/wp-admin/post-new.php?post_type=mylink&special=278

    but there’s no value for the hidden field in the database. (all the other metabox fields work perfectly)

    https://wordpress.org/plugins/meta-box/

  • The topic ‘Passing URL param to hidden field’ is closed to new replies.