Skip Navigation

[Resolved] creating a select author form in cred

This support ticket is created 8 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 10 replies, has 2 voices.

Last updated by Minesh 8 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#363809

I am trying to make a select author field for a CRED form for a new post. The Select Box does not show up

the current code goes as follows:

for the view- content to load: This View selects users with role subscriber ordered by user login, ascending

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
        <wpv-loop>
        [wpv-item index=1]
          {"value":"[wpv-user field="ID"]","label":"[wpv-user field="user_firstname"] [wpv-user field="user_lastname"]"}   
        [wpv-item index=other],
          {"value":"[wpv-user field="ID"]","label":"[wpv-user field="user_firstname"] [wpv-user field="user_lastname"]"}
</wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]

for the form:

[credform class='cred-form cred-keep-original']
	[cred_field field='form_messages' value='']


	<div class="cred-field cred-field-post_title">
		<label class="cred-label">
Website Client Name
</label>
    [cred_generic_field field="my_author_select" type="select" class="" urlparam=""]
        {
            "required":0,
            "validate_format":0,
            "persist":1,
            "default":[],
            "options":[ [wpv-view  name="List Authors"] ]
        }
    [/cred_generic_field]
	</div>

for the datahook in functions.php

// Custom Author Selection for CRED
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==357)
    
{
$my_post = array(
      'ID'           => $post_id,
      'post_author' => $_POST['my_author_select']
  );
   
// Update the post into the database
  wp_update_post( $my_post );
}
}
#363863

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Could you please try to add following code to your current theme's functions.php file:

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );
  
function prefix_clean_view_output( $out, $id ) {
    if ( $id == '375' ) { //Please adjust to your Views ID
        $start = strpos( $out, '<!-- wpv-loop-start -->' );
        if ( 
            $start !== false
            && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
        ) {
            $start = $start + strlen( '<!-- wpv-loop-start -->' );
            $out = substr( $out , $start );
            $end = strrpos( $out, '<!-- wpv-loop-end -->' );
            $out = substr( $out, 0, $end );
        }
    }
    return $out;
}

Where:
Replace '375' with your view Id.

I hope this will resolve your issue.

#364073

Now the Select Box is showing up but it is not being populated.

#364286

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

1)
Could you please send me link of the page where you've inserted CRED form?

2)
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#364644

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I'll start to work on issue - is that fine with you?

#364652

Go ahead

#364671

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I just realized after login to your wp-admin that I do not have sufficient access, I can see only profile page. Could you please allow me full rights so that I can move forward with the issue.

#364682

Minesh I'm not sure how to send you this information privately. Please send an email to richard@hascoagency.com

#364683

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've set next reply as private. Only you can I can see the private reply. Please send me.

#364700

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

wp-admin.png

I'm able to access your admin but I need full rights so that I can able to see your issue, posts etc..et..

Please see attached screenshots what I can see now.

I've set next reply as private.

#364974

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I can see that you have created view "List Authors" with role = "Subscriber" and when I've checked your users' list I can see that you have only one user with role = Subscriber and that user do not have first name as well as last name information.

Please check this:
=> ww.your-domain.com/wp-admin/user-edit.php?user_id=5&wp_http_referer=%2Fwp-admin%2Fusers.php

Now, if you will input first name and last name values with above mentioned user you will be able to see dropdown with one entry I believe. Could you please check and try to resolve your issue.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.