Skip Navigation

[Gelöst] CRED – using data (ID etc.) of the created post in success message

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

The issue here is that the user wanted to display the created post ID on their form submission message.
Solution:
Unfortunately this seems not to be possible however the user opted to redirect to the page that was created using CRED by using the following hook

//redirect after post creation
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==150) //Change this to your form's ID
     
      //Get that Post's Permalink of Target Page 
      $permalink = get_permalink(130);
  
      //Return the URL to where to redirect: 
      return $permalink."?created_post_id=".$post_id ;
    
    return $url;
}
This support ticket is created vor 6 Jahren, 8 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von KonstantinS88 vor 6 Jahren, 7 Monaten.

Assistiert von: Shane.

Author
Artikel
#631826

When I create a new post with a CRED form I want to have a link that contains the ID of the just created post. useable within the text message.

How can I use the ID of the created post in the message form? All I got so far is the ID of the page the CRED form is inserted in.

The reason I want to acchieve this is that I want to have a link in the message guiding to another cred form with the ID of the created post (of the first cred form) set as a url parameter for a preselected parent. meaning: You have to create the "object" (a bolok for example) first and can then directly "review" it.

Thanks in advance.

#632029

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Konstantin,

Could you try adding this attribute to the shortcode and let me know if it works.

id='%%POST_ID%%'

Thanks,
Shane

#654529

Unfortunately this returns a 0 when used in a shortcode and just %%POST_ID%% when used inside a standard a link.

#656060

Guess this is not possible which I wonder about a little. Tried everything . Even used the cred message shortcode. Fininally I did something else:

//redirect after post creation
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==150) //Change this to your form's ID
    
      //Get that Post's Permalink of Target Page 
      $permalink = get_permalink(130);
 
      //Return the URL to where to redirect: 
      return $permalink."?created_post_id=".$post_id ;
   
    return $url;
}

Nonehtless, I feed like the "created post ID" should defginitely be available in the feedback message.